<template>
	<view class="work-detail" id="work-detail">
		<offline-banner ref="offline" :top="statusBarHeight" :planId="planId" @refresh="refreshData"></offline-banner>

		<view class="header">
			<view :class="[showNav ? 'aa' : '']" style="z-index: 300">
				<global-nav-bar @setHeight="setHeight" type="black" left-icon="back" color="#333" :title="title"
					:fixed="false" backgroundColor="rgba(0, 0, 0, 0)"></global-nav-bar>
			</view>
			<!-- 头部部分header -->
			<view class="header_item" style="">
				<view class="header_top">
					<view class="header_top_left" @click.stop="toEleDetail">
						<text style="vertical-align: middle">{{
							eleInfo.elevatorAddress || offlineDetail.elevatorAddress
						}}</text>
						<uni-icons color="#999" size="16" type="arrowright" />
					</view>
					<!-- <view class="flex" style="width: 94rpx;margin-left: auto;" v-if="eleInfo.latitude" @click.stop="toMap">
						<image src="/static/images/maintain/location.png" class="close"
							style="width: 32rpx;height: 32rpx;"></image>
						导航
					</view> -->
					<view @click.prevent="changeState" class="statusArea" :style="{
						color:
							eleInfo.isStop == 1 || offlineDetail.elevatorIsStop == 1
								? '#0091ff'
								: '#E02020',
						zIndex: showNav ? 110 : 120,
					}">{{
						eleInfo.isStop == 1 || offlineDetail.elevatorIsStop == 1
							? "正常运行"
							: "停梯"
					}}
						<image v-if="eleInfo.isStop == 1 || offlineDetail.elevatorIsStop == 1" class="statusSwich"
							src="@/static/images/blue.png" mode=""></image>
						<image v-if="eleInfo.isStop == 2 || offlineDetail.elevatorIsStop == 2" class="statusSwich"
							src="@/static/images/red.png" mode=""></image>
					</view>
				</view>
				<!-- <view class="header_bottom">{{ eleInfo.buildingAddress }}</view> -->
				<view class="header_bottom" @click="toInfo" style="display: flex; justify-content: space-between;">
					<view class="header_bottomTops">
						<text>{{ eleInfo.brandName || "-" }}</text>
						<text>{{ eleInfo.privateNum || "-" }}</text>
					</view>
					<view v-if="!eleInfo.isFull" style="display: flex; align-items: center;" @click.stop="toMorePage">
						<view class="bottom">待完善资料</view>
						<uni-icons color="#999" size="18" type="arrowright" />
					</view>
				</view>
			</view>
			<image
				src="https://592800-erised-fresh.oss-cn-shenzhen.aliyuncs.com/upload/20221012/c1a6e9996af7e11408d283b788eb2b33.png"
				mode="" class="bg"></image>
		</view>
		<view class="main">
			<view class="addressBox">
				<view class="addressBox_left">
					<view class="top">
						<view class="name">
							<image src="@/static/images/index/buildIcon.svg" mode=""></image>
							<view style="margin-left: 10rpx">{{
								eleInfo.buildingName || offlineDetail.buildingName
							}}</view>
						</view>
					</view>
					<view class="buildAddress" style="display: flex; align-items: center" @click.stop="petName(eleInfo)"
						v-if="eleInfo.relationAlias && eleInfo.relationAlias.length">
						<view class="buildings">项目别名:{{
							eleInfo.relationAlias.map((item) => item.alias).join(",")
						}}</view>
						<view>
							<uni-icons :type="popupShow ? 'arrowup' : 'arrowdown'" size="14" color="#999;"></uni-icons>
						</view>
					</view>
					<view class="buildAddress" @click.stop="toProjectDetail">{{
						eleInfo.buildingAddress || offlineDetail.buildingAddress
					}}</view>
				</view>
				<view class="addressBox_right">
					<view class="gpsAndCall">
						<view class="gpsAndCall_item" @click.stop="handleCall"
							v-if="eleInfo.estateUserList && eleInfo.estateUserList.length">
							<image src="@/static/images/phone3.png" mode=""></image>
							<view>物业</view>
						</view>
						<view class="gpsAndCall_item guide" @click.stop="toMap">
							<image src="@/static/images/locations.png" mode=""></image>
							<view>导航</view>
						</view>
						<view class="line" v-if="eleInfo.estateUserList && eleInfo.estateUserList.length"></view>
					</view>
				</view>
			</view>
			<!-- header end -->
			<view class="headers" :style="{ paddingTop: paddingTop }">
				<!-- <view class="headers-bg"></view> -->

				<view class="mark">
					<!-- 头部部分 -->
					<!-- 计划时间 -->
					<view class="progressBar_planTime">
						<view class="planTime_tit">
							<view class="">计划时间
								<text class="planBar" v-if="overdueName">
									{{
										overdueName.indexOf("已") !== -1
											? overdueName.substring(1, overdueName.length)
											: overdueName
									}}
								</text>
								<text class="planBar" v-if="timeliness && timeliness != '及时'"
									style="background: #fdf1e9; color: #fa6400">
									{{
										timeliness.indexOf("已") !== -1
											? timeliness.substring(1, timeliness.length)
											: timeliness
									}}
								</text>
							</view>

						</view>
						<view class="planTime_date">

							<view class="date_text" @click="handleTime">
								<text v-if="planDetail.planDate">{{
									planDetail.planDate.substring(0, 10).replaceAll("-", "/")
								}}</text>
								<text v-if="!planDetail.planDate && offlineDetail.planDate">
									{{
										offlineDetail.planDate
											.substring(0, 10)
											.replaceAll("-", "/")
									}}
								</text>
								<image v-if="isShowFn" src="/static/images/index/switchComp2.png" mode=""></image>
							</view>
							<!-- <view class="" @click="specialClick"
							v-if="planDetail.auditType === 2 && (!overdueName || overdueName == '及时') && planDetail.status === 1">
							<text>特殊延期</text>
							<image src="@/static/images/maintain/tips.png" mode=""></image>
						</view> -->
						</view>
					</view>

					<!-- 备注入口 -->
					<view v-if="!((status === 3 || status === 4 || status === 5) && remarkLength === 0)"
						class="remark-btn" @click="toRemark">
						<view style="display:flex;align-items: center;">
							<view>无法保养登记</view>
							<zb-tooltip arrowLeft="-80" placement="bottom-start" ref="tooltip">
								<image style="width:29rpx;height:28rpx;margin-left:10rpx; margin-top: 8rpx;"
									src="@/static/images/index/q.png"></image>
								<view class="tipsContent" slot="content">
									<view class="">因客户或其他因素导致无法保养，可登记相关理由</view>
								</view>
							</zb-tooltip>
						</view>
						<uni-icons color="#666" size="13" type="arrowright" />
					</view>

				</view>
				<!-- 备注 end -->

				<!-- 进度条 -->
				<view class="stepContent">
					<view class="stepItme">
						<view class="steps">
							<view class="finishDateContent" v-if="status == 1 && planDetail.planDate">
								<view class="label">系统预估耗时</view>
								<view class="timeArea">
									<text style="color: #0091ff">{{ systemTime.hour }}小时{{ systemTime.min }}分</text>
								</view>
							</view>
							<view class="finishDateContent" v-if="status == 2 && planDetail.planDate">
								<view class="label">预计保养结束时间</view>
								<view class="timeArea" @click="showChooseDate">
									<text>{{ `${dateArr[0]}年` }}</text>
									<text style="color: #0091ff">
										{{ `${dateArr[1]}月${dateArr[2]}日` }}
										<text v-if="todayStr">{{ `(${todayStr})` }}</text>
										{{ `${dateArr[3]}:${dateArr[4]}` }}
									</text>

									<image src="@/static/images/edit2.png" mode="" />
								</view>
							</view>
							<view class="finishDateContent" v-if="status == 2 && !planDetail.planDate">
								<view class="label">预计保养结束时间</view>
								<view class="timeArea" @click="showChooseDate">
									<text>{{ offLineSignRecord.finishDate }}</text>

									<image src="@/static/images/edit2.png" mode="" />
								</view>
							</view>
							<stautsStep :actIndex="stepActIdx" :list="stepList" :log="logs"></stautsStep>
						</view>
						<view @click="goTaskSetpPage" class="userListBox">
							<user-list v-if="!offline" :list="planDetail.users">
							</user-list>
							<user-list v-else :list="offUsers"> </user-list>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 头部电梯信息end -->

		<!-- <view class="card" v-if="offline">
        <offlineBlock :btn="false" height="38vh">
          <view v-if="offLineSignRecord.planId == planId">
            <view>网络离线</view>
            <view>在线后才可执行工单</view>
          </view>
          <view v-else> 网络离线，仅可签到 </view>
        </offlineBlock>
      </view> -->

		<!-- 工单评分 -->
		<view class="card" v-if="planDetail &&
			planDetail.maintainPlanContentExt &&
			planDetail.maintainPlanContentExt.scoreType
		">
			<view class="title">
				<view>工单评分</view>
				<view style="color: #666;font-size: 24rpx;font-weight: normal;display: flex;align-items: center;"
					@click="$refs.lookScore.open()">
					<text>查看详情</text>
					<uni-icons color="#000000" size="14" type="arrowright" />
				</view>
			</view>
			<view style="padding: 0 20rpx;">
				<view class="score_content">
					<view class="label">有效判定</view>
					<view class="msg">{{ planDetail.maintainPlanContentExt.scoreType == 1 ? '有效工单' :
						planDetail.maintainPlanContentExt.scoreType == 2 ? '无效工单' : '无法判断' }}</view>
				</view>

				<view class="score_content"
					v-if="planDetail.maintainPlanContentExt.scoreType == 1 || planDetail.maintainPlanContentExt.scoreType == 2">
					<view class="label">工单评分</view>
					<view class="msg">{{ planDetail.maintainPlanContentExt.score + "分" }}</view>
				</view>
				<view class="score_content">
					<view class="label" style="margin-top:7rpx">整体评价</view>
					<view class="msg" v-if="planDetail.maintainPlanContentExt.scoreFutilityDesc"> <text class="tags"
							v-for="(item, index) in planDetail.maintainPlanContentExt.scoreFutilityDesc.split(',')"
							:key="index">{{
								item }}</text></view>
				</view>
				<view class="score_content" v-if="planDetail.maintainPlanContentExt.scoreFutilityOtherDesc">
					<view class="label">其他评价</view>
					<view class="msg">{{ planDetail.maintainPlanContentExt.scoreFutilityOtherDesc || '--' }}</view>
				</view>
				<!-- <view class="score_content">
              <view class="label">评分人</view>
              <view class="msg">{{ planDetail.maintainPlanContentExt.scoreUserName }}</view>
            </view> -->
				<view class="score_content">
					<view class="label">评分备注</view>
					<view class="msg">{{ planDetail.maintainPlanContentExt.scoreRemark || '--' }}</view>
				</view>
				<view class="score_content" style="padding-bottom: 30rpx;">
					<view class="label" style="width: auto">{{ planDetail.maintainPlanContentExt.scoreDate }}</view>
				</view>
			</view>

		</view>

		<view class="card" v-if="!sign && !customerSign" :style="fixedStatus ? 'padding-top:200rpx' : ''">
			<view class="sticky" id="sticky" :style="{
				top: mheight + 'px',
				position: fixedStatus ? 'fixed' : 'static',
			}">
				<view class="title">任务详情
					<view v-if="configValue == 1 && status == 2 && isPlanStatus && !sign" @click="chooseAllCheck"
						:class="allChecked ? 'allcheck allcheckAct' : 'allcheck'">
						<image v-if="allChecked" src="/static/images/maintain/allchecked.png" mode=""></image>
						<image v-if="!allChecked" src="/static/images/maintain/allcheck.png" mode=""></image>
						全选正常
					</view>
				</view>
				<tabBar :showRed="errorView ? true : false" :typeMap="typeMap" :list="loacls" :actIndex="tabIdx"
					@change="changeTab"></tabBar>
				<view class="template-tabs">
					<view :class="['template-item', templateId == item.id ? 'act' : '']" @click="chooseTemplate(item)"
						v-for="(item, index) in templateTabs" :key="item.id">
						{{ item.name }}
					</view>
				</view>
			</view>
			<view class="temp-list">
				<!-- <view class="temp-list-name">{{ item.templateName }}</view> -->
				<templateTrees @setNode="setNodeEmit" :pictureDisable="pictureDisable" :planId="planId"
					@preViewVideo="preViewVideo" :isPlanStatus="isPlanStatus" :status="status" @addrecord="addrecordFuc"
					:tree="templateTypeVOS">
				</templateTrees>
			</view>
			<view class="empty" v-if="templateTypeVOS.length == 0">
				<view class="circle">
					<image src="@/static/images/default.png"></image>
				</view>
				<view class="empty-title">
					~暂无相关数据~
				</view>
			</view>
		</view>
		<view v-if="sign" class="card">
			<view class="title">维保签字</view>
			<view class="canvas">
				<image v-if="signImg" :style="{
					display: 'block',
					border: '1rpx dashed #ccc',
					margin: '0 auto',
					width: width + 'px',
					height: width + 'px',
				}" class="signimg" :src="signImg" mode="aspectFill"></image>
				<zwp-draw-pad @drawfuc="drawfuc" v-if="width && !signImg" ref="drawPad" :width="width"
					:height="width" />
			</view>
			<view class="sign-btns" v-if="!signImg">
				<view class="sign-btns-item" @click="sign = false">返回任务列表</view>
				<view class="sign-btns-item" @click="clearSign">清除重写</view>
				<view class="sign-btns-item" @click="signSave(1)">提交</view>
			</view>
			<!-- <view class="vertical tips" v-if="item.tips && !item.signatureImg">请在本区域用正楷手写签名</view> -->
		</view>
		<!-- 客户签字 -->
		<view v-if="customerSign" class="card">
			<view class="title">客户签字</view>
			<view class="canvas">
				<image v-if="customerSignImg" :style="{
					display: 'block',
					border: '1rpx dashed #ccc',
					margin: '0 auto',
					width: width + 'px',
					height: width + 'px',
				}" class="signimg" :src="customerSignImg" mode="aspectFill"></image>
				<zwp-draw-pad @drawfuc="drawfuc" v-if="width && !customerSignImg" ref="drawPad" :width="width"
					:height="width" />
			</view>
			<view class="sign-btns" v-if="!customerSignImg">
				<view class="sign-btns-item" @click="customerSign = false">返回任务列表</view>
				<view class="sign-btns-item" @click="clearSign">清除重写</view>
				<view class="sign-btns-item" @click="signSave(2)">提交</view>
			</view>
			<!-- <view class="vertical tips" v-if="item.tips && !item.signatureImg">请在本区域用正楷手写签名</view> -->
		</view>

		<view class="card signCard" id="signBlock" v-if="signRecords.length > 0 && !customerSign && !offline">
			<view class="card_item" v-if="mSignList.length && !sign">
				<view class="title">维保签字</view>
				<view class="sign-item" v-for="(item, index) in mSignList" :key="index">
					<view class="sign-item-name">
						{{ item.userName }}签字
						<view class="sign-item-line"></view>
					</view>

					<image :src="item.signImg" mode="widthFix"></image>
				</view>
			</view>
			<view class="card_item" v-if="cSiginList.length">
				<view class="title">客户签字</view>
				<view class="sign-item" v-for="(item, index) in cSiginList" :key="index">
					<image :src="item.signImg" mode="widthFix"></image>
				</view>
			</view>
		</view>
		<!-- 底部占位 -->
		<view class="footer-block"></view>
		<!-- 底部占位end -->

		<view class="footer" v-if="!sign && !customerSign">
			<view v-if="offLineSignRecord.planId == planId && offline" @click="postOffRecord" class="btn">
				已签到，点击刷新</view>
			<view v-if="status == 1 || (status == 2 && userSignCount == 0 && offLineSignRecord.planId != planId)"
				@click="nextStepFuc" class="btn">
				开始签到
			</view>
			<view v-if="status == 2 && userSignCount > 0 && offline && !offLineSignRecord.planId != planId"
				@click="postOffRecord" class="btn">
				工单已在线签到，请刷新数据</view>
			<view class="btn repair" @click="toFlex" v-if="status == 2 && userSignCount > 0 && !sign && onlineStatus">
				发起维修
			</view>

			<view class="btn" @click="finish" v-if="isAllDone && status == 2 && userSignCount > 0 && !sign && !offline"
				style="border-radius: 0rpx 8rpx 8rpx 0rpx">提交任务</view>
			<view class="btn" @click="nextWorkItem"
				v-if="!isAllDone && status == 2 && userSignCount > 0 && !sign && !offline"
				style="border-radius: 0rpx 8rpx 8rpx 0rpx">
				查看下一个必填项
			</view>

			<view class="btn" @click="toSign" v-if="status == 3 && !hasSign && !sign && !offline">签字确认</view>
			<view class="btn disabled" v-if="status == 3 && hasSign && !sign && !offline">请等待同伴签字</view>
			<!-- <view class="btn disabled" v-if="status == 3 && hasSign">已签字</view> -->
			<view class="btn" v-if="status == 4" @click="backToList">返回任务列表</view>
			<view class="btn" v-if="status == 5 && hasSign && !customerSign && !offline" @click="customerHandleSign"
				:class="[!judgeSignObj.result ? 'disabled' : '']">客户签字</view>
			<!-- <view class="sign-btns-item" v-if="status == 3 && !signImg">返回任务列表</view> -->
		</view>

		<!-- 申诉入口按钮 S -->
		<view class="appeal-btn" @click="toAppeal" v-if="status >= 3 && appealNum > 0">
			<image class="appeal-btn-ico" src="@/static/images/ai_blue.png"></image>
			申诉
		</view>
		<!-- 申诉入口按钮 E -->

		<uni-popup ref="popup">
			<timeSignin :type="signType" :lists="imgaddress ? [imgaddress] : []" :signinData="eleInfo" parentStyle="0"
				@close="finishSign" @changeImg="changeImg" />
		</uni-popup>

		<videoDialog ref="videoDialog" @closed="hideVideo" v-if="showVideo" :video="preVideo"></videoDialog>

		<recordDialog :planInfo="planInfo" :planId="planId" ref="recordDialog" @addRecord="finishAddRecord"
			:show="showRecordEdit" @closed="showRecordEdit = false"></recordDialog>
		<!-- 电梯状态弹窗 -->
		<model title="请选择电梯状态" :maskClick="false" @cancle="cancleChange" @comfire="comfireChange"
			:visible="visibleShowTwo">
			<view class="change_elevator">
				<view @click="changeElevator(1)" :class="elevatorStatus === 1 ? 'actElevator' : ''">正常运行</view>
				<view @click="changeElevator(2)" :class="elevatorStatus === 2 ? 'actElevator' : ''">停梯</view>
			</view>
		</model>

		<model title="AI检测提示" comfireTxt="前往申诉" cancleTxt="跳过" @cancle="aiModelClick(false)"
			@comfire="aiModelClick(true)" :visible="aiResultModel">
			<view class="lastImg" v-if="lastSignImg">
				已检测当前工单，存在<text style="color:#e02020">不合规</text>风险图片。若对检测结果有异议，可在工单提交任务后，进行申诉。
			</view>
		</model>

		<!-- 年审梯特殊延期弹窗 -->
		<model title="特殊延期" :changeComfire="true" :widthS="'580rpx;'" :comfireTxt="'我要特殊延期'" :cancleTxt="'我知道了'"
			:maskClick="false" @cancle="cancleChange" @comfire="specialFuc" :visible="specialShow">
			<view class="special_tit">
				<view class="tit_up">
					仅用于年审梯因不可抗力因素,导致需要延期超过1天的场景。
				</view>
				<view class="tit_dwn">
					特殊延期可能导致年审梯保养存在违规风险，请谨慎操作。
				</view>
			</view>
		</model>
		<action-sheet ref="actionSheet"></action-sheet>
		<!-- 时间选择 -->
		<week-year-date ref="weekYear" :showState="showState" @selectChange="selectChange"
			@bindClose="bindClose"></week-year-date>
		<!-- 物业电话 -->
		<property-phone ref="property" @bindClose="closePhone" :list="eleInfo.estateUserList"></property-phone>
		<view class="signCircle" v-if="status == 2 && !sign && userSignCount > 0"
			:style="{ left: movable.x + 'px', top: movable.y + 'px' }" @touchmove.stop="movableChange"
			@touchend="touchend">
			<view class="add" @click.stop="showStatusChangeBeforeLeave(false)" v-if="isPlanStatus">签退</view>
			<view class="add" v-if="!isPlanStatus && userSignCount > 0 && !offline" @click="nextStepFuc">
				{{ "继续" }}
			</view>
		</view>
		<!-- 使用上次照片 -->
		<model :title="signType == 'in' ? '签到拍照提示' : '签退拍照提示'" :maskClick="false" @cancle="comfireUseLastImg(false)"
			@comfire="comfireUseLastImg(true)" :visible="visibleShowLastImg">
			<view class="lastImg" v-if="lastSignImg">
				{{
					`是否使用上次${signType == "in" ? lastSignImg.signTime : lastSignImg.signOutTime
					}【${signType == "in"
						? lastSignImg.signTypeStatusDesc
						: lastSignImg.signOutTypeStatusDesc
					}工单】的${signType == "in" ? "签到" : "签退"}拍照?`
				}}
			</view>
		</model>
		<!-- 项目别名弹窗 -->
		<aliasPopup :showAlias="popupShow" :aliasArr="aliasArr" @closedMask="closedMask"></aliasPopup>

		<!-- 有未签退的工单 -->
		<model title="有未签退的保养任务" :maskClick="false" comfireTxt="去签退" width="500rpx" :showCloseIcon="false"
			@cancle="signOutModelVisible = false" @comfire="toNotSignOutOrder" :visible="signOutModelVisible">
			<not-sign-out-model :msg="checkCanSignOutMsg"></not-sign-out-model>
		</model>
		<!-- 查看评分详情 -->
		<uni-popup ref="lookScore" :mask-click="true" type="bottom">
			<lookScore @handleSave="$refs.lookScore.close()" :msg="planDetail.maintainPlanContentExt"></lookScore>
		</uni-popup>

		<!-- #ifdef MP-WEIXIN -->
		<view @touchmove.stop.prevent class="camera-dialog" v-if="showCamera">
			<waterMark ref="waterMark" pageType="2" @back="cameraClose" />
		</view>
		<!-- #endif -->

		<aiResize ref="aiResize"></aiResize>
		<previewMedia ref="previewMedia"></previewMedia>
		<!-- showBottom -->

		<uni-popup ref="multiUserPopup" :mask-click="true" type="bottom">
			<view class="multiUser">
				<view class="multiUser_title" @click="$refs.multiUserPopup.close">
					<view class="line"></view>
					<view class="tips">提示</view>
				</view>
				<view style="height: 2rpx;background: #EEEEEE;"></view>
				<view class="multiUser_content">
					<view class="content_tips">工单当前作业人数不足2人，暂无法提交</view>
					<view class="content_remarks">因法规要求，年审梯保养作业必须2人以上</view>
					<view class="content_remarks">计划执行人:</view>
					<view class="people_box">
						<view :class="['people', item.signUser && item.signUser.isTakePartIn ? 'signOnPeople' : '']"
							v-for="(item, index) in planDetail.users" :key="index">
							<view>{{ item.userName }}</view>
							<view :class="['tags', item.signUser && item.signUser.isTakePartIn ? 'signOn' : '']">{{
								item.signUser && item.signUser.isTakePartIn ? '已签到' : '未签到' }}</view>
						</view>
					</view>
				</view>
				<view style="height: 2rpx;background: #EEEEEE;"></view>
				<view class="multiUser_bottom">
					<view class="btn" @click="$refs.multiUserPopup.close">我知道了</view>
				</view>
			</view>
		</uni-popup>

		<uni-popup ref="workTimePopup" :mask-click="true" type="bottom">
			<view class="multiUser">
				<view class="multiUser_title" @click="$refs.workTimePopup.close">
					<view class="line"></view>
					<view class="tips">提示</view>
				</view>
				<view style="height: 2rpx;background: #EEEEEE;"></view>
				<view class="multiUser_content" style="padding-bottom: 0;">
					<view class="content_tips">工单当前作业人数不足2人，暂无法提交</view>
					<view style="display: flex; justify-content: space-between; align-items: center;margin-top: 24rpx;">
						<view>
							<view style="color: #666;">当前已作业</view>
							<view>{{ planDetail.workDuration }}分钟</view>
						</view>
						<view style="text-align: right;">
							<view style="color: #666;">作业时长要求(以上)</view>
							<view>{{ config.cheWorkTime }}分钟</view>
						</view>
					</view>
				</view>
				<view class="multiUser_content" style="padding-bottom: 68rpx;">
					<view
						style="width: 100%; height: 32rpx; background: #EBF7FF; border-radius: 16rpx; margin-top: 12rpx; overflow: hidden;">
						<view :style="{
							width: ((planDetail.workDuration / (config.cheWorkTime || 1)) * 100 > 100 ? 100 : (planDetail.workDuration / (config.cheWorkTime || 1)) * 100) + '%',
							height: '100%',
							background: '#0091ff',
							borderRadius: '16rpx',
							transition: 'width 0.3s'
						}"></view>
					</view>
				</view>
				<view style="height: 2rpx;background: #EEEEEE;"></view>
				<view class="multiUser_bottom">
					<view class="btn" @click="$refs.workTimePopup.close">我知道了</view>
				</view>
			</view>
		</uni-popup>

	</view>

</template>

<script>
import lookScore from './components/lookScore.vue';
import stautsStep from './components/statusStep.vue';
import tabBar from './components/tabBar.vue';
import videoDialog from './components/videoDialog.vue';
import unipopup from '@/components/uni-popup/uni-popup.vue';
import timeSignin from '@/components/timeSignin/timeSignin.vue';
import UserList from '@/components/user-list/user-list.vue';
import recordDialog from './components/recordDialog.vue';
import model from '@/components/model/index.vue';
import GlobalNavBar from '@/components/uni-nav-bar/global-nav-bar';
import actionSheet from '../components/actionSheet/index.vue';
import aliasPopup from '@/components/card-dial/aliasPopup.vue';
import aiResize from '../components/ai-resize/ai-resize.vue';
import waterMark from '@/pages/camera/camera.vue';
import templateTrees from './components/templateTree/templateTree.vue';
// import zbTooltip from '@/components/zb-tooltip/zb-tooltip.vue'
import dayjs from 'dayjs';
import {
	elevtorDetail,
	changeElevatorState,
	changeElevatorStoplog,
} from '@/apis/elevator.js';
import { getDiffYear, getlocalinfo, getBeforeDate } from '@/utils/utils.js';
import { getDistance } from '@/utils/tools.js'; // 经纬度距离计算
import { timeUpdate, getConfig, checkCanSignOut } from '@/apis/sign.js';
import PropertyPhone from '@/components/propertyPhone/index.vue';
import WeekYearDate from '@/components/dateSelect/index.vue';
import offlineBlock from '@/components/offline-block/offline-block.vue';
import NotSignOutModel from '../components/notSignOutModel/index.vue';
import { getSyncData, setOfflineWorkerItem, setListStatus, setLocalPlan, getLocalPlan, setSyncData } from '@/utils/offline.js';
import {
	getLoaclTypes,
	getPlanDetail,
	getAllWorkItems,
	signatureList,
	signIn,
	signOut,
	finishPlan,
	signaturePlan,
	customSign,
	workItemsUpdate,
	workItemUpdate,
	getPlanLogs,

} from '@/apis/workOrder.js';
import { mapState, mapActions } from 'vuex';
import { getMaintainSet } from '@/apis/setting.js';
import { getAIImages } from '@/apis/system.js';
export default {
	components: {
		offlineBlock,
		GlobalNavBar,
		stautsStep,
		tabBar,
		unipopup,
		timeSignin,
		videoDialog,
		UserList,
		recordDialog,
		model,
		actionSheet,
		PropertyPhone,
		WeekYearDate,
		aliasPopup,
		NotSignOutModel,
		lookScore,
		waterMark,
		aiResize,
		templateTrees
	},
	provide() {
		return {

		};
	},
	data() {
		return {
			aiResultModel: false,
			showCamera: false,// 打开水印相机
			statusBarHeight: 0,
			overflowShow: false,
			offTimer: null,
			offLineSignRecord: {},
			offline: false,
			offlineDetail: {}, // 离线数据
			systemTime: {
				hour: 0,
				min: 0,
			},
			pictureDisable: 1,// 指引开关 1 关
			configValue: 0, // 设置值 0-关 1-开
			fixedStatus: false,
			stickyTop: 0,
			stickyHeight: 0,
			signTop: 0,
			mheight: 0,
			allChecked: false,
			typeMap: {
				all: 0
			},
			showNav: false,
			editIdx: -1,
			isEdit: false,
			showVideo: false,
			preVideo: '',
			signImg: '',
			draw: false,
			sign: false,
			signRecords: [], // 签字列表
			hasSign: false, // 是否已签字
			status: 0,
			planStatus: 1,
			title: '',
			topheight: '',
			scrollTop: 0,

			signinData: {},
			planId: '',
			loacls: [],
			tabIdx: 0,
			eleInfo: {},
			imgaddress: '',
			stepList: [
				{
					status: 1,
					name: '待开始',
					icon: '/static/images/specials/s1.png',
				},
				{
					status: 2,
					name: '进行中',
					icon: '/static/images/specials/s2.svg',
				},
				{
					status: 3,
					name: '提交任务',
					icon: '/static/images/specials/s5.svg',
				},
				{
					status: 3,
					name: '维保签字',
					icon: '/static/images/specials/s3.svg',
				},
				{
					status: 3,
					name: '客户签字',
					icon: '/static/images/specials/s3.svg',
				},
				{
					status: 4,
					name: '已完成',
					icon: '/static/images/specials/s4.svg',
				},
			],
			logs: [],
			workItemMap: {},// 工作项表 方便读取
			orgTemplate: [],// 所有工作项列表
			templateTabs: [],// 模板筛选列表
			templateId: '',
			templateTypeVOS: [],// 工作项列表
			planDetail: { users: [], maintainSignature: false },
			signType: 'in', // 打卡弹窗类型  in 签到 out签退
			showRecordEdit: false,
			isPlanStatus: false, // 我自己是否还未签退
			userSignCount: 0,
			timeWait: null, // 自动滚动定时
			errorView: null,
			elevatorStatus: 1, // 电梯状态
			visibleShowTwo: false,
			customerSign: false, // 客户是否签字过
			customerSignImg: '',
			mAllSigin: false, // 维保员是否全部签字完成
			judgeSignObj: {}, // 判断客户签字是否置灰
			mSignList: [], // 维保员签字列表
			cSiginList: [], // 客户签字列表
			isOutInState: false, // 提交任务后电梯确定状态

			showLeave: false, // 确定电梯状态后是否走签退逻辑
			handFinish: false, // 签退后是否走维修完成逻辑，
			specialShow: false, // 年审特殊延期弹窗状态
			planCheckName: '', // 任务类型名称
			timeliness: '', // 超时文本
			overdueName: '', // 逾期文本
			lastSignImg: '', // 上次拍照的内容
			maintainPlanContentExt: {},
			choosePlanDate: false,
			useLastImg: false, // 是否使用上次的照片
			config: {},
			visibleShowLastImg: false, // 上次图片
			movable: {
				x: 320,
				y: 0,
				height: 0,
				width: 0,
			},
			finishDate: '', // 预计完成时间
			dateArr: [],
			showState: false,
			showchangeTips: false,
			buttonType: null, // 区分按钮类型发送群消息
			popupShow: false,
			aliasArr: [],
			signOutModelVisible: false,
			checkCanSignOutMsg: {}, // 未签退的工单信息

			incompleteMap: {
				// 未完成的工作项
			},
			isAllDone: true,// 是否全部完成全部工作项
			workerItemNodes: {

			},
			remarkLength: 0,
		 
			// 待申诉数量
			appealNum: 0,
		};
	},

	computed: {
		...mapState('user', ['userinfo']),
		...mapState('system', ['onlineStatus']),// 离线状态 ture 在线
		planInfo() {
			return {
				buildingId: this.eleInfo.buildingId,
				buildingName: this.eleInfo.buildingName,
				elevatorId: this.eleInfo.id,
				elevatorAddress: this.eleInfo.elevatorAddress,
				planId: this.planId,
				planWorkItemId: '',
				partsId: '',
			};
		},
		paddingTop() {
			return `calc(${this.topheight} + 44px)`;
		},
		width() {
			return uni.upx2px(355 * 2 - 42);
		},
		offUsers() {
			// 离线签到用户
			const users = this.offlineDetail.signUsers || [];
			let arr = [];
			for (let i = 0; i < users.length; i++) {
				arr.push({
					userName: users[i].userName,
					userId:
						users[i].userName == this.userinfo.nick_name
							? this.userinfo.user_id
							: -1,
					signUser: users[i],
				});
			}
			return arr;
		},
		customHasSign() {
			return this.signRecords.find((item) => {
				return item.signType == 2;
			})
				? true
				: false;
		},
		// 进度条到哪里
		stepActIdx() {
			let res = 0;
			if (this.status == 4) {
				res = 6;
			} else if (this.status == 5) {
				res = 4;
			} else {
				res = this.status;
			}
			return res;
		},
		isShowFn() {
			let result = false;
			// 显示操作按钮
			if (
				this.planDetail.status === 1 &&
				(this.planDetail.auditType === 1 || this.planDetail.auditType === 2) &&
				(!this.timeliness || this.timeliness == '及时')
			) {
				result = true;
			}
			// 不显示操作按钮 年审梯 已延期特殊延期过 并且等于当前日期
			if (
				(this.maintainPlanContentExt.deferType === 1 ||
					this.maintainPlanContentExt.deferType === 5) &&
				new Date(this.planDetail.planDate.replaceAll('-', '/')).getTime() /
				1000 ===
				new Date(dayjs().format('YYYY/MM/DD')).getTime() / 1000
			) {
				return false;
			}

			return result;
		},
		todayStr() {
			let today = getBeforeDate(0);
			let tomorrow = getBeforeDate(-1);
			let afterTomorrow = getBeforeDate(-2);
			let str = this.finishDate.substring(0, 10);
			if (str == today) {
				return '今天';
			} else if (str == tomorrow) {
				return '明天';
			} else if (str == afterTomorrow) {
				return '后天';
			} else {
				return '';
			}
		},
	},
	watch: {
		onlineStatus(val) {
			if (!val) {// 网络状态更变离线 获取本地详情
				this.pictureDisable = 1;// 离线暂时关闭指引（加载不出占位大
				this.getLocalPlan();
			} else {
				this.$refs.offline.changeStatus();
			}
		},
		// 工单状态
		status(val) {
			// console.log('xxx',val);
			// this.getAiAppeals(false);
		},
	},
	// 监听页面滚动
	onPageScroll(e) {
		this.scrollTop = e.scrollTop;

		// console.log('e.scrollTop',e.scrollTop,this.signTop,this.stickyTop,this.stickyHeight,this.mheight)
		if (e.scrollTop > 20) {
			this.showNav = true;
			this.title = this.eleInfo.elevatorAddress || this.offlineDetail.elevatorAddress;
			this.scrollTop = e.scrollTop;
		} else {
			this.showNav = false;
			this.title = '保养详情';
		}

		// 任务类别吸顶逻辑
		if (e.scrollTop > this.stickyTop - this.mheight) {
			if (
				this.signTop &&
				e.scrollTop > this.signTop - this.stickyTop + this.mheight + 80
			) {
				this.fixedStatus = false;
			} else {
				this.fixedStatus = true;
			}
		} else {
			this.fixedStatus = false;
		}
	},

	async onLoad(res) {
		this.title = '保养详情';
		this.planId = res.planId;
		this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 44;
		uni.showLoading({
			title: '加载中',
			mask: true,
		});
		this.elevatorId = res.elevatorId;
		uni.$on('openCamera', (data) => {
			this.openCamera(data);
		});
		this.initDetail();
	},
	onUnload() {
		// 关闭页面前清除全局事件监听
		uni.$off('openCamera');
		uni.$off('isFinsh');
		uni.$off('preViewVideo');
		uni.$off('addrecord');
		uni.$off('Type' + this.planId);
		uni.$off('scrollToView');
		if (this.offTimer) {
			clearInterval(this.offTimer);
			this.offTimer = null;
		}
	},
	onHide() {
		if (this.offTimer) {
			clearInterval(this.offTimer);
			this.offTimer = null;
		}
	},
	async onShow(os) {
		console.log('onShow', os);
		this.refreshData();
	},
	mounted() {
		uni.getSystemInfo({
			success: (res) => {
				// console.log("system", res);
				this.movable.height = res.windowHeight - 100;
				this.movable.y = res.windowHeight - 240;
				this.movable.width = res.windowWidth;
				this.movable.x = this.movable.width - 55;
			},
		});
	},
	methods: {
		...mapActions('user', ['handleRreshToken']),

		cameraClose() {
			this.showCamera = false;
		},
		// 水印相机打开钩子
		openCamera(data) {
			// #ifdef MP-WEIXIN
			this.showCamera = true;
			this.$nextTick(() => {
				this.$refs.waterMark.init(data);
				this.$refs.waterMark.setStatus();
			});
			// #endif
			// #ifdef H5 
			let params = [];
			if (data) {
				for (const key in data) {
					if (data[key]) {
						params.push(`${key}=${data[key]}`);
					}
				}
			}

			uni.navigateTo({
				url: '/pages/camera/camera' + (params.length ? `?${params.join('&')}` : ''),
				fail: (err) => {
					console.log(err);
				},
			});
			// #endif
		},
		// 初始化详情基础设置与数据
		async initDetail() {
			if (!this.userinfo.user_id) {
				await this.handleRreshToken();
			}
			if (!this.userinfo.user_id) {
				return;
			}
			// this.getLocalPlan()

			// 监听工作项点击查看作业指引
			uni.$off('preViewVideo');
			uni.$on('preViewVideo', (data = '') => {
				this.preViewVideo(data);
			});
			// 监听工作项点击添加或编辑记录

			uni.$on('addrecord', (data) => {
				this.addrecordFuc(data);
			});

			// 监听滚动到区域内时间
			uni.$off('scrollToView');
			uni.$on('scrollToView', (data) => {
				this.scrollToViewFuc(data);
			});
			// 监听工作项完成状态变化
			uni.$off('workitemStatusUpdate' + this.planId);
			uni.$on('workitemStatusUpdate' + this.planId, (res) => {
				if (!res.id) {
					return;
				}
				if (this.workItemMap[res.templateId + '_' + res.id] && res) {
					this.workItemMap[res.templateId + '_' + res.id].finished = res.finished || false;// finished true 已完成
					for (let i = 0; i < this.loacls.length; i++) {
						if (this.loacls[i].checkHistorys[res.templateId + '_' + res.id]) {
							this.loacls[i].checkHistorys[res.templateId + '_' + res.id].finished = res.finished || false;
							break;
						}
					}
					this.updateLocalTotals();
				}

				// throttles(this.updateLocalTotals, 500) //更新分类栏已完成数量(节流)
			});

			// 工作项修改，同步数据
			uni.$off('workitemUpdate' + this.planId);
			uni.$on('workitemUpdate' + this.planId, (res) => {
				this.workItemUpdate(res);// push工作项修改数据到远程 
			});

			uni.$off('isFinsh');
			uni.$on('isFinsh', async (res) => {
				if (res) {
					await this.getPlanDetail();
					this.initElevtorDetail();
					this.finishFuc();
				}
			});

			uni.$off('Type' + this.planId);
			uni.$on('Type' + this.planId, (res) => {
				let loacls = JSON.parse(JSON.stringify(this.loacls));
				let data = JSON.parse(JSON.stringify(res));
				let all = [];
				let len = 0;
				for (const key in data) {
					if (key.indexOf('suc') == -1) {
						all.push(...data[key]);
						for (let i = 0; i < loacls.length; i++) {
							if (loacls[i].tltId == key) {
								loacls[i].sucCount = data[key].length;
								break;
							}
						}
					}
				}
				for (let i = 0; i < loacls.length; i++) {
					if (loacls[i].tltId) {
						len = len + Number(loacls[i].sucCount);
					}
				}

				if (loacls.length) {
					loacls[0].sucCount = len;
				}
				this.loacls = loacls;
				data['all'] = all;
				this.updataAllCheckStatus();
				this.$forceUpdate();
			});

			// 存储所有工作项节点，方便提交时校验（h5）
			uni.$off('setNode' + this.planId);
			uni.$on('setNode' + this.planId, async (res) => {
				this.setNodeEmit(res);
			});

			this.fixedStatus = false;
			if (this.onlineStatus) {// 在线模式 获取个人保养设置
				this.getMaintainSet();// 获取个人保养设置(开关等)
				this.getConfig();
			}
		},

		setNodeEmit(res) {
			if (res && res.templateContentId) {
				this.workerItemNodes[res.templateContentId] = res.node;
			}
		},
		// 遍历工作项，触发每个工作项的校验
		callWorkerItemNodes() {
			for (const key in this.workerItemNodes) {
				this.workerItemNodes[key].watchFinish({ view: this.errorView });
			}
		},

		// 刷新数据(工单状态信息与工作项详情等)
		async refreshData() {
			if (this.onlineStatus) {
				if (this.templateTypeVOS.length) {
					await this.getWorkOredrDetail(false);
					await this.getPlanDetail();

					let detail = { ...this.eleInfo, ...this.planDetail, elevatorId: this.elevatorId, planId: this.planId };
					detail.loacls = this.loacls;
					detail.templateTabs = this.templateTabs;
					detail.orgTemplate = this.orgTemplate;
					const waitplan = uni.getStorageSync('workingPlans');
					if (!waitplan || waitplan.indexOf(this.planId) == -1) {
						// 缓存详情数据
						this.setLocalData(detail);
					}
					return;
				}
				this.getAiAppeals(false);
				// 在线 
				await this.initElevtorDetail();
				await this.getPlanDetail();
				let loacls = await this.getLocals();
				if (!loacls || loacls.length == 0) {
					uni.hideLoading();
					uni.showModal({
						title: '提示',
						content: '此模板暂无数据，请重新选择',
						success() {
							uni.navigateBack({});
						},
						showCancel: false,
					});
					return;
				}
				await this.getWorkOredrDetail();

				let detail = { ...this.eleInfo, ...this.planDetail, elevatorId: this.elevatorId, planId: this.planId };
				detail.loacls = this.loacls;
				detail.templateTabs = this.templateTabs;
				detail.orgTemplate = this.orgTemplate;
				const waitplan = uni.getStorageSync('workingPlans');
				if (!waitplan || waitplan.indexOf(this.planId) == -1) {
					console.log('test-缓存详情数据', detail);
					// 缓存详情数据
					this.setLocalData(detail);
				}
				console.log('test-缓存详情数据-off');

				// this.$nextTick(() => {
				// 	this.setSignStyle();
				// });
			} else {
				// 离线
				this.pictureDisable = 1;
				this.getLocalPlan(this.templateTypeVOS.length ? false : true);
			}
		},

		// 将工单详情数据存到本地
		setLocalData(data) {
			console.log('detail1', data);
			setLocalPlan(this.planId, data);
		},

		// 获取离线工单详情
		async getLocalPlan(first = true) {
			let detail = await getLocalPlan(this.planId);
			console.log('获取离线工单详情', detail);

			this.offlineDetail = detail;
			if (detail.planDate) {
				if (!this.planDetail.planDate) {
					// this.planDetail.planDate=detail.planDate

					this.timeliness = detail.timeliness;
					this.overdueName = detail.overdueName;
					this.planCheckName = detail.planCheckName;
					this.lastSignImg = detail.lastSignImg;
					this.judgeSignObj = detail.signatureEstateStatus || {};// 客户是否可以签字
					this.finishDate = detail.finishDate || '';

					if (detail.finishDate != null) {
						let timeArr = detail.finishDate
							.replace(' ', ':')
							.replace(/\:/g, '-')
							.split('-');
						this.dateArr = timeArr;
					} else {
						let date = dayjs().format('YYYY-MM-DD');
						let hour = Number(dayjs().format('HH')) + 2;
						let min = dayjs().format('mm');
						let arr = [...date.split('-'), hour, min];
						this.dateArr = arr;
						this.finishDate = `${date} ${hour}:${min}`;
					}
				} else {

				}
				this.status = detail.status;
				this.planDetail.users = detail.users;
				this.isPlanStatus = this.setIsPlanStatus();
				this.loacls = detail.loacls;
				this.templateTabs = detail.templateTabs;
				if (this.templateTabs.length > 0) {
					this.templateId = this.templateTabs[0].id;
				}
				this.setSystemTime(detail.templateInfo);

				this.orgTemplate = detail.orgTemplate;
				this.setWorkItemMap(this.orgTemplate);// 遍历初始化每个工作项
				this.initLocalIds(); 

				// 签字相关 start
				this.setSignRecords(detail.signRecords);
				// 签字相关 end

				this.changeTab(0, first);
				if (first) {
					this.$nextTick(() => {
						this.setStickyStyle();
						uni.$emit('setFinishStatus' + this.planId);
						uni.hideLoading();
					});
				}
			}
		},

		// 分发签字记录数据
		setSignRecords(list) {
			let signRecords = list || [];
			this.signRecords = signRecords;
			this.mSignList = signRecords.filter((item) => {
				return item.signType == 1;
			});
			this.cSiginList = signRecords.filter((item) => {
				return item.signType == 2;
			});
			for (let i = 0; i < signRecords.length; i++) {
				if (signRecords[i].userId == this.userinfo.user_id) {
					this.hasSign = true;
					return;
				}
			}
			this.hasSign = false;
		},

		// 提交工作项数据
		workItemUpdate(formData) {
			const result = formData.recordData.userData ? formData.recordData.userData.result : '1';
			console.log('提交工作项数据', formData, result);
			this.setOrgWorkItem(formData);
			if (!this.onlineStatus) {
				let item = this.workItemMap[formData.templateId + '_' + formData.templateContentId];
				item.result = result;
				item.recordData = formData.recordData;
				item.userRecordVOS = formData.userRecordVOS;
				item.updateTime = dayjs().format('YYYY-MM-DD HH:mm:ss');

				setSyncData('checkHistories', item);// 添加工作项待同步缓存
				return;
			}

			// 检查该工作项是否完成
			this.loading = true;
			return new Promise((resolve) => {
				workItemUpdate({
					planId: formData.planId,
					id: formData.checkHistoryId,
					result: result,
					recordData: formData.recordData
				}).then((res) => {
					setOfflineWorkerItem(this.planId, formData); // 同步到离线详情

					if (formData.recordData.type == 3 || formData.recordData.type == 4) {
						// 如果图片视频题目，提交后刷新一遍数据
						this.refreshData();
					}
					resolve();
				}).catch(() => {
				});
			});
		},

		setOrgWorkItem(item) {
			for (let i = 0; i < this.orgTemplate.length; i++) {
				if (this.orgTemplate[i].templateId == item.templateId && this.orgTemplate[i].templateContentId == item.templateContentId && this.orgTemplate[i].tltIds == item.tltIds) {
					// console.log(111)
					// this.$set(this.orgTemplate, i, item);
					this.orgTemplate.splice(i, 1, item);
					break;
				}
			}

			for (let j = 0; j < this.templateTypeVOS.length; j++) {
				let list = this.templateTypeVOS[j].planTemplateContentVOS || [];
				for (let k = 0; k < list.length; k++) {
					if (list[k].templateId == item.templateId && list[k].templateContentId == item.templateContentId && list[k].tltIds == item.tltIds) {
						// console.log(222) 
						list.splice(k, 1, item);

						return;
					}
				}
			}
		},

		// 更新分类栏已完成数量
		updateLocalTotals() {
			if (this.loacls.length == 0) {
				return;
			}
			let finishNum = 0; // 总
			for (let i = 0; i < this.loacls.length; i++) {
				let num = 0;
				for (const key in this.loacls[i].checkHistorys) {
					if (this.loacls[i].checkHistorys[key] && this.loacls[i].checkHistorys[key].finished) {
						num++;
					}
				}
				finishNum = finishNum + num;
				this.loacls[i].finished = num;
			}
			this.loacls[0].finished = finishNum;
			this.allChecked = this.loacls[0].finished == this.loacls[0].workItemCount;

			return;
		},
		toNotSignOutOrder() {
			uni.navigateTo({
				url: `/subpages/workOrders/detail?planId=${this.checkCanSignOutMsg.planId}&elevatorId=${this.checkCanSignOutMsg.elevatorId}`
			});
			this.signOutModelVisible = false;
		},
		toRemark() {
			let result = this.planDetail.users.some(
				(item) => item.userId === this.userinfo.user_id
			);
			// 0 无权限
			uni.navigateTo({
				url: `/subpages/workOrders/remarks?planId=${this.planId}&status=${this.status}&role=${result ? 1 : 0}`
			});
		},

		// 获取全部正常开关
		getMaintainSet() {
			getMaintainSet({
				userId: this.userinfo.user_id,
			}).then((res) => {
				// console.log("getMaintainSet", res);
				this.configValue = res.data.configValue || 0;
				this.pictureDisable = (res.data.pictureDisable === undefined || res.data.pictureDisable === null) ? 1 : res.data.pictureDisable;
			});
		},

		// 获取吸顶高度
		setSignStyle() {
			let que = wx.createSelectorQuery();
			que.select('#signBlock').boundingClientRect((res) => {
				if (res && res.top) {
					this.signTop = this.scrollTop + res.top;
				} 
				que = null;
			})
				.exec();
		},
		// 获取吸顶高度
		setStickyStyle() {
			if (this.stickyTop == 0) {
				let que = wx.createSelectorQuery();
				que
					.select('#sticky')
					.boundingClientRect((res) => {
						console.log('sticky', res);
						this.stickyTop = this.scrollTop + res.top - res.height;
						this.stickyHeight = res.height;
						que = null;
					})
					.exec();
			}
		},
		setHeight(n) {
			this.mheight = n;
			// this.pageHight = this.pageHight - n
		},
		// 更新全部正常异常状态
		updataAllCheckStatus() {
			if (this.loacls[0].sucCount == this.loacls[0].workItemCount) {
				this.allChecked = true;
			} else {
				this.allChecked = false;
			}
		},
		// 全选正常
		chooseAllCheck() {
			uni.showLoading({
				title: '加载中',
				mask: true,
			});
			let arr = [];
			let ids = [];
			const setCheckItem = (list) => {
				for (let i = 0; i < list.length; i++) {
					if (list[i].children) {
						setCheckItem(list[i].children);
					} else {
						for (
							let k = 0;
							k < (list[i].planTemplateContentVOS || []).length;
							k++
						) {
							let item = list[i].planTemplateContentVOS[k];
							if (item.recordData && item.recordData.type == 1) {
								let jso = {};
								if (this.allChecked) {
									jso = {
										recordData: {
											...item.recordData,
											userData: JSON.parse(
												JSON.stringify(item.recordData.options[0])
											),
											userChoose: 0,
										},
										result: 1,

										planId: this.planId,
										id: item.checkHistoryId,
									};
								} else {
									jso = {
										recordData: {
											...item.recordData,
										},
										result: '0',

										planId: this.planId,
										id: item.checkHistoryId,
									};
									delete jso.recordData.userChoose;
									delete jso.recordData.userData;
								}
								arr.push(jso);
								ids.push(item.checkHistoryId);
							}
						}
					}
				}
			};

			this.allChecked = !this.allChecked;
			setCheckItem(this.templateTypeVOS);

			workItemsUpdate(arr).then((res) => {
				uni.hideLoading();
			});

			uni.$emit('Check' + this.planId, {
				allChecked: this.allChecked,
				ids: ids,
			});

			/* 定位上报埋点*/
			// this.reportAddress({
			//   userId: this.userinfo.user_id,
			//   operation: 4,
			//   planId: this.planId,
			//   recordType: 1, //
			// });
			/* 定位上报埋点 end*/
			this.$forceUpdate();
		},
		// 跳转电梯详情
		toEleDetail() {
			if (!this.onlineStatus) {
				this.offLineTips();
				return;
			}
			uni.navigateTo({
				url: `/subpages/elevator/projectInfo/eleDetail?id=${this.elevatorId}`,
			});
		},
		// 跳转项目详情
		toProjectDetail() {
			if (this.offline) {
				this.offLineTips();
				return;
			}
			uni.navigateTo({
				url: '/pageModules/projectInfo/detail?id=' + this.eleInfo.buildingId,
			});
		},
		// 定位下一项未完成工作项
		async nextWorkItem() {
			this.errorView = null;
			if (this.templateId == '' && this.tabIdx == 0) {
				this.callWorkerItemNodes();
			} else {
				this.templateId = '';
				await this.changeTab(0); // 同步数据
				uni.showLoading({
					title: '同步中请稍后',
					mask: true,
				});
				await this.awaitTimeOut(2000);
				this.callWorkerItemNodes();
				uni.hideLoading();
			}
			setTimeout(() => {
				if (!this.errorView) {
					this.isAllDone = true;
				}
			}, 1000);
			uni.hideLoading();
		},
		// 检测到有未完成工作项 自动滚动到区域内
		scrollToViewFuc(res) {
			if (this.errorView) {
				// console.log('自动滚动到区域内',res)
				return;
			}
			this.isAllDone = false;
			this.errorView = res.workitem;

			console.log('自动滚动到区域内',
				res.workitem.name,
				res,
				res[0].top,
				this.scrollTop,
				res[0].top - 100 + this.scrollTop
			);

			// #ifdef MP-WEIXIN
			uni.pageScrollTo({
				scrollTop: res[0].top - 280 + this.scrollTop, // 滚动到页面节点的上边界坐标
				duration: 400, // 滚动动画的时长
			});
			// #endif

			// #ifdef H5  
			const element = document.getElementById(res[0].id);
			// console.log('自动滚动到区域内H5', element, res[0].id)
			if (element) {
				element.scrollIntoView({ behavior: 'smooth' });
			}
			// #endif
		},
		// 年审特殊延期
		specialClick() {
			// 只有自己的任务
			if (this.planDetail.users && this.planDetail.users.length > 0) {
				let result = this.planDetail.users.some(
					(item) => item.userId === this.userinfo.user_id
				);
				if (!result) {
					uni.showModal({
						title: '提示',
						content: '你没有权限操作该任务',
						showCancel: false,
						confirmText: '我知道了',
						success: (res) => {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						},
					});
					return;
				}
			}

			this.specialShow = true;
		},

		// 前往ai图片审核页 finish 0（普通跳转） 1（带提交按钮）
		toAppeal(finish = 0) {
			uni.navigateTo({
				url: `/pages/imageAppeal/index?finish=${finish}&planId=${this.planId}`
			});
		},
		// 年审特殊延期确定
		specialFuc() {
			let needObj = {
				planId: this.planId,
				buildingAddress:
					this.eleInfo.buildingName + this.eleInfo.elevatorAddress,
				planCheckName: this.planCheckName,
				planDate: this.planDetail.planDate,
				auditType: this.planDetail.auditType,
				elevatorId: this.elevatorId,
			};
			uni.navigateTo({
				url:
					'/pageModules/yearTrial/calendarEdit?needObj=' +
					JSON.stringify(needObj) +
					'&nums=' +
					4,
			});
			this.specialShow = false;
		},
		// 调整记录页面
		toYearDelay() {
			let needObj = {
				planId: this.planId,
				buildingAddress:
					this.eleInfo.buildingName + this.eleInfo.elevatorAddress,
				planCheckName: this.planCheckName,
				planDate: this.planDetail.planDate,
				auditType: this.planDetail.auditType,
				deferType: this.planDetail.deferType,
			};
			uni.navigateTo({
				url:
					'/pageModules/yearTrial/operationLog?needObj=' +
					JSON.stringify(needObj),
			});
		},

		// 选择年审和非年审调整入口
		handleTime() {
			if (!this.isShowFn) {
				return;
			}
			if (!this.onlineStatus) {
				this.offLineTips();
				return;
			}

			// 只有自己的任务
			if (this.planDetail.users && this.planDetail.users.length > 0) {
				let result = this.planDetail.users.some(
					(item) => item.userId === this.userinfo.user_id
				);
				if (!result) {
					uni.showModal({
						title: '提示',
						content: '你没有权限操作该任务',
						showCancel: false,
						confirmText: '我知道了',
						success: (res) => {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						},
					});
					return;
				}
			}

			// this.$nextTick(()=>{
			//     console.log(this.$refs.planDatePopup,'this的值');
			// 		this.choosePlanDate=true
			// 	  this.$refs.actionSheet.$refs.actionSheet.open()
			// })

			// return
			// let arr = ['延期保养', '提前保养']
			let arr = [{ name: '延期保养' }, { name: '提前保养' }];
			if (
				this.planDetail.status === 1 &&
				(!this.overdueName || this.overdueName == '及时')
			) {
				// 待开始+未逾期
				if (this.planDetail.auditType === 2) {
					// 年审类型
					arr = [{ name: '延期保养' }];
					if (
						this.planDetail.maintainPlanContentExt.deferType === 5 ||
						this.planDetail.maintainPlanContentExt.deferType === 1
					) {
						// 被特殊年审延期过后
						arr = [{ name: '提前保养' }];
					}

					// 年审梯 已延期特殊延期过 并且等于当前日期
					if (this.planDetail.planDate) {
						if (
							(this.planDetail.maintainPlanContentExt.deferType === 1 ||
								this.planDetail.maintainPlanContentExt.deferType === 5) &&
							new Date(
								this.planDetail.planDate.replaceAll('-', '/')
							).getTime() /
							1000 ===
							new Date(dayjs().format('YYYY/MM/DD')).getTime() / 1000
						) {
							return;
						}
					}
				}
				if (this.planDetail.auditType === 1) {
					// 非年审类型
					if (this.planDetail.planDate) {
						if (
							new Date(
								this.planDetail.planDate.replaceAll('-', '/')
							).getTime() /
							1000 <=
							new Date().getTime() / 1000
						) {
							// 小于等于今天任务的日期只显示延期
							arr = [{ name: '延期保养' }];
						}
					}
				}
				// 如果有特殊延期
				if (
					this.planDetail.auditType === 2 &&
					(!this.overdueName || this.overdueName == '及时') &&
					this.planDetail.status === 1
				) {
					arr = [...arr, { name: '特殊延期' }];
				}
				// 调整记录
				arr = [...arr, { name: '调整记录' }];

				this.$refs.actionSheet.showActionSheet({
					itemList: arr,
					success: (res) => { 
						let needObj = {
							planId: this.planId,
							buildingAddress:
								this.eleInfo.buildingName + this.eleInfo.elevatorAddress,
							planCheckName: this.planCheckName,
							planDate: this.planDetail.planDate,
							auditType: this.planDetail.auditType,
						};
						if (this.planDetail.auditType === 1) {
							// 非年审
							let str = '';
							if (res.tapIndex === 0) {
								// 去延期保养页面
								str =
									'/pageModules/yearTrial/calendarEdit?needObj=' +
									JSON.stringify(needObj) +
									'&nums=' +
									1;
								uni.navigateTo({
									url: str,
								});
							}
							if (res.tapIndex === 1) {
								// 去提前保养页面
								str = '/pageModules/yearTrial/calendarEdit?needObj=' + JSON.stringify(needObj) + '&nums=2';
								uni.navigateTo({
									url: str
								});
							}
						}
						if (this.planDetail.auditType === 2) {
							// 年审
							if (res.tapIndex == 0 && arr[0].name === '延期保养') {
								uni.navigateTo({
									url:
										'/pageModules/yearTrial/yearDelay?needObj=' +
										JSON.stringify(needObj),
								});
							}
							if (res.tapIndex == 0 && arr[0].name === '提前保养') {
								uni.navigateTo({
									url:
										'/pageModules/yearTrial/calendarEdit?needObj=' +
										JSON.stringify(needObj) +
										'&nums=' +
										3,
								});
							}
						}
						if (res.val.name == '特殊延期') {
							this.specialClick();
						}
						if (res.val.name == '调整记录') {
							this.toYearDelay();
						}
					},
					fail(res) { },
				});
			}
		},

		// 弹窗提示
		changeState() {
			if (this.offline) {
				this.offLineTips();
				return;
			}
			if (this.status === 4 || this.status == 3) {
				let title = this.status == 4 ? '任务已完成' : '任务已提交';
				uni.showToast({
					title: title,
					icon: 'none',
					mask: true,
				});
				return;
			}
			if (this.userSignCount == 0) {
				uni.showModal({
					title: '提示',
					content: '请先签到开始再进行操作',
					showCancel: false,
				});
				return;
			}
			this.visibleShowTwo = true;
		},
		cancleChange() {
			this.visibleShowTwo = false;
			this.specialShow = false;
			this.elevatorStatus = this.eleInfo.isStop;
		},
		// 更改电梯状态
		changeElevator(nums) {
			this.elevatorStatus = nums;
		},
		// 确定
		comfireChange() {
			uni.showLoading({
				title: '加载中',
				icon: 'none',
			});
			if (this.isOutInState) {
				// 提交任务电梯状态选确定时
				this.isOutInState = false;
				this.finishFuc();
			}
			if (this.eleInfo.isStop === this.elevatorStatus) {
				uni.hideLoading();
				this.visibleShowTwo = false;
				if (this.showLeave) {
					this.finishOut('');
				}
				return;
			}
			changeElevatorState({
				id: this.elevatorId,
				isStop: this.elevatorStatus,
			})
				.then((res) => {
					uni.hideLoading();
					uni.showToast({
						title: '电梯状态切换成功',
						icon: 'none',
						mask: true,
					});
					this.visibleShowTwo = false;
					if (this.showLeave) {
						this.finishOut('');
					}
					changeElevatorStoplog({
						elevatorId: this.elevatorId,
						initStatus: this.eleInfo.isStop,
						setStatus: this.elevatorStatus,
						module: `${this.planId}`,
						position: 6
					}).then((res) => { });
					this.initElevtorDetail();
				})
				.catch((err) => {
					uni.hideLoading();
				});
		},

		// 发起维修
		toFlex() {
			if (this.offline) {
				this.offLineTips();
				return;
			}
			uni.navigateTo({
				url: `/pageModules/barrierSearch/barrierPage?elevatorId=${this.elevatorId}
        &elevatorName=${this.eleInfo.elevatorAddress}&elevatorAddress=${this.eleInfo.buildingAddress}&type=1&formPage=maintain&planId=${this.planId}`,
			});
		},

		// 电梯信息详情页
		toInfo() {
			if (!this.onlineStatus) {// 离线模式
				this.offLineTips();
				return;
			}
			uni.navigateTo({
				url: '/subpages/elevator/projectInfo/elevatorInfoPage?id=' + this.elevatorId,
			});
		},
		toMorePage() {
			uni.navigateTo({
				url: `/subpages/elevator/projectInfo/eleDetail?id=${this.eleInfo.id}&type=` + 3
			});
		},
		getAliasStr(str) {
			if (!str) {
				return '';
			}
			if (str.length > 20) {
				return '(项目别名：' + str.slice(0, 20) + '...)';
			} else {
				return '(项目别名：' + str + ')';
			}
		},
		// 地图导航
		toMap() {
			let alias = this.eleInfo.relationAlias || this.offlineDetail.relationAlias;
			let aliasName = alias.length
				? alias
					.map((item) => {
						return item.alias;
					})
					.join(',')
				: '';
			uni.openLocation({
				latitude: Number(this.eleInfo.latitude || this.offlineDetail.latitude),
				longitude: Number(this.eleInfo.longitude || this.offlineDetail.longitude),
				name: (this.eleInfo.buildingName || this.offlineDetail.buildingName) + this.getAliasStr(aliasName),
				address: this.eleInfo.buildingAddress || this.offlineDetail.buildingAddress,
				fail: (err) => {
					console.log(err);
				},
			});
		},
		// 我自己是否还未签退
		setIsPlanStatus() {
			console.log('setIsPlanStatus', this.planDetail.users);
			for (let i = 0; i < this.planDetail.users.length; i++) {
				if (
					this.planDetail.users[i].userId == this.userinfo.user_id &&
					this.planDetail.users[i].signUser
				) {
					this.userSignCount = this.planDetail.users[i].userSignCount;
					return this.planDetail.users[i].signUser.isPlanStatus;
				}
			}
			this.userSignCount = 0;
			return false;
		},
		addrecordFuc(form) {
			if (!this.$refs['recordDialog']) {
				return;
			}

			this.showRecordEdit = true;
			this.$nextTick(() => {
				this.$refs['recordDialog'].initData(form);
			});
		},
		// 任务状态详情，维保员列表等信息
		getPlanDetail() {
			console.log('get任务状态详情');
			return new Promise((resolve) => {
				getPlanDetail({ planId: this.planId })
					.then((res) => {
						this.planDetail = res.data;
						this.maintainPlanContentExt = res.data.maintainPlanContentExt || {};
						this.isPlanStatus = this.setIsPlanStatus();
						this.status = res.data.status;
						this.timeliness = res.data.timeliness;
						this.overdueName = res.data.overdueName;
						this.planCheckName = res.data.planCheckName;
						this.lastSignImg = res.data.lastSignImg;

						this.judgeSignObj = res.data.signatureEstateStatus || {};// 客户是否可以签字
						// 预计完成时间
						this.finishDate = res.data.finishDate;
						if (res.data.finishDate != null) {
							let timeArr = res.data.finishDate
								.replace(' ', ':')
								.replace(/\:/g, '-')
								.split('-');
							this.dateArr = timeArr;
						} else {
							let date = dayjs().format('YYYY-MM-DD');
							let hour = Number(dayjs().format('HH')) + 2;
							let min = dayjs().format('mm');
							let arr = [...date.split('-'), hour, min];
							this.dateArr = arr;
							this.finishDate = `${date} ${hour}:${min}`;
						}
						if (this.status > 2) {
							this.signatureList();
						}
						this.$nextTick(() => {
							this.setStickyStyle();
						});
						this.setSystemTime(this.planDetail.templateInfo);

						uni.$emit('itemUpdate', { planId: this.planId, status: this.status });// 更新列表卡片状态

						setListStatus({ planId: this.planId, status: this.status });
						resolve();
					})
					.catch(async (err) => {
						console.log('getPlanDetail', err);
						if (err.errMsg) {
							// 网络问题 走离线 
						}
					});
			});
		},

		// 计算系统预估耗时
		setSystemTime(templateInfo) {
			let mind = 0;
			let timelist = templateInfo || [];
			for (let i = 0; i < timelist.length; i++) {
				mind = mind + (timelist[i].workDay || 0) * 60 * 24;
				mind = mind + (timelist[i].workHour || 0) * 60;
				mind = mind + (timelist[i].workMin || 0);
			}
			this.systemTime = {
				hour: Math.floor(mind / 60),
				min: mind % 60,
			};
		},

		// 任务追踪页面
		goTaskSetpPage() {
			if (!this.onlineStatus) {
				this.offLineTips();
				return;
			}
			// this.eleInfo.planCheckType = 9; //专项保养 
			this.eleInfo.planId = this.planId;
			this.eleInfo.planCheckName = this.planCheckName;
			this.eleInfo.planDate = this.planDetail.planDate;
			this.eleInfo.auditType = this.planDetail.auditType; 
			uni.navigateTo({
				url:
					'/subpages/workOrders/components/taskStepPage?obj=' +
					JSON.stringify(this.eleInfo)
			});
		},
		// 完成添加工作项描述记录
		finishAddRecord() {
			this.refreshData();
		},

		// 获取电梯详情信息
		initElevtorDetail() {
			return new Promise((resolve) => {
				elevtorDetail({
					elevatorId: this.elevatorId,
				}).then((res) => {
					let obj = res.data || {};
					if (Object.keys(obj).length) {
						this.eleInfo = obj;
						this.elevatorStatus = obj.isStop;
						let tempDate = obj.madeDate ? obj.madeDate.substring(0, 10) : 0;
						this.elevatorYear = tempDate !== 0 ? getDiffYear(tempDate) : '';

						// 设置水印缓存
						let data = {
							buildingId: this.eleInfo.buildingId,
							buildingName: this.eleInfo.buildingName,
							elevatorId: this.elevatorId,
							elevatorAddress: this.eleInfo.elevatorAddress,
							planId: this.planId,
							planWorkItemId: '',
							partsId: '',
						};
						uni.setStorage({
							key: 'waterMarkMsg',
							data,
							success: (success) => {

							},
						});
					}
					resolve();
				}).catch(() => {
					resolve();
				});
			});
		},
		hideVideo() {
			this.showVideo = false;
			this.$forceUpdate();
		},
		preViewVideo(url = '') {
			if (typeof url != 'string') {
				return;
			}
			this.preVideo = url;

			this.showVideo = true;
		},

		// 签退前确定电梯状态
		async showStatusChangeBeforeLeave(res, type) {
			// if (this.offline) {
			//   uni.showToast({
			//     title: "无网络，不可签退",
			//     icon: "none",
			//   });
			//   return;
			// } 
			this.handFinish = res;
			// this.showLeave = true;
			// this.visibleShowTwo = true;
			this.signType = 'out';
			let isFinsh = res ? true : false;
			const data = {
				signType: this.signType == 'in' ? 1 : 2,
				useLastImg: this.useLastImg,
				orderType: 1,
			};
			this.buttonType = type;
			if (type === 1) {
				// 区分按钮类型发送群消息
				data.buttonType = 1;
				this.buttonType = 1;
			}
			uni.setStorage({
				key: 'signObj',
				data,
			});
			// console.log(this.config, "this.config");
			if (this.config.cheSignOut == 1) {
				if (this.onlineStatus && this.lastSignImg && this.lastSignImg.signOutImage) {
					this.visibleShowLastImg = true;
				} else {
					uni.navigateTo({
						url: `/pages/sign/index?planId=${this.planId}&elevatorId=${this.elevatorId}&isFinsh=${isFinsh}`,
					});
				}
			} else {
				uni.navigateTo({
					url: `/pages/sign/index?planId=${this.planId}&elevatorId=${this.elevatorId}&isFinsh=${isFinsh}`,
				});
			}
		},

		// 签退 post==> 是否签退后立即执行提交操作 签退后是否立即执行提交任务
		async finishOut() {
			const post = this.handFinish ? true : false;
			this.showLeave = false;
			let localInfo = await this.getLocalInfo();
			if (!localInfo.latitude) {
				// uni.showModal({
				//   title: "提示",
				//   content: "请打开定位，再签退",
				//   showCancel: false,
				// });
				// return;
				uni.showToast({
					title: '请打开定位，再签退',
					icon: 'none',
					mask: true,
				});
			}
			// 计算是否范围内打卡
			let distance = getDistance(
				localInfo.latitude,
				localInfo.longitude,
				this.eleInfo.latitude,
				this.eleInfo.longitude
			);
			if (distance > this.$config.maxDistance) {
				uni.showModal({
					title: '提示',
					content: '当前不在项目位置,是否确定按照当前位置继续签退？',
					success: (res) => {
						if (res.confirm) {
							this.signType = 'out';
							this.signinData = { post: post || false };

							// 判断是否使用上次照片
							let data = {
								signType: this.signType == 'in' ? 1 : 2,
								useLastImg: this.useLastImg,
								orderType: 1,
							};
							uni.setStorage({
								key: 'signObj',
								data,
							});
							if (this.config.cheSignOut == 1) {
								// 直接跳转
								if (this.lastSignImg && this.lastSignImg.signOutImage && this.onlineStatus) {
									this.visibleShowLastImg = true;
								} else {
									uni.navigateTo({
										url: `/pages/sign/index?planId=${this.planId}&elevatorId=${this.elevatorId}&isFinsh=${post}`,
									});
								}
							} else {
								// 没有打开开关直接跳转
								uni.navigateTo({
									url: `/pages/sign/index?planId=${this.planId}&elevatorId=${this.elevatorId}&isFinsh=${post}`,
								});
							}
						}
					},
				});

				return;
			}
			this.signType = 'out';
			this.signinData = {
				post: post || false,
			};
			const data = {
				signType: this.signType == 'in' ? 1 : 2,
				useLastImg: this.useLastImg,
				orderType: 1,
			};
			uni.setStorage({
				key: 'signObj',
				data,
			});
			uni.navigateTo({
				url: `/pages/sign/index?planId=${this.planId}&elevatorId=${this.elevatorId}&isFinsh=${isFinsh}`,
			});

			// 去签退页面
			// this.$refs.popup.open("center");
		},
		// 打开签名画板
		drawfuc() {
			this.draw = true;
		},
		// 清空签名
		clearSign() {
			this.draw = false;
			this.$refs.drawPad.init();
		},
		// 生成图片
		signSave(type) {
			if (this.getPlanRole() == false) {
				return;
			}
			if (!this.draw) {
				uni.showToast({
					title: '无签字，请签字后确认',
					icon: 'none',
					mask: true,
				});
				return;
			}
			uni.showModal({
				title: '',
				content: '请确认签字是否正确，任务提交后将不可修改',
				success: (res) => {
					if (res.confirm) {
						if (this.onlineStatus) {
							/* 定位上报埋点*/
							this.reportAddress({
								userId: this.userinfo.user_id,
								operation: type == 1 ? 6 : 7, // 签字
								planId: this.planId,
								recordType: 1, //
							});
							/* 定位上报埋点 end*/
						}

						uni.showLoading({
							title: '生成中',
							mask: true,
						});
						const options = {
							x: 0,
							y: 0,
							width: this.width,
							height: this.width,
							destWidth: this.width,
							destHeight: this.width,
						}; // 就这几个属性，其他的不要传；这些属性都有默认值，所以一般不用传options参数,直接调save()就可以了
						this.$refs.drawPad.save(options).then(async (res) => {
							console.log('保存图片的地址', res.tempFilePath);
							if (!this.onlineStatus) {
								// 离线情况，图片不上传服务器
								let signture = {
									planId: this.planId,
									userId: this.userinfo.user_id,
									userName: this.userinfo.nick_name,
									signType: type == 1 ? 1 : 2,
									signImg: res.tempFilePath
								};
								if (type == 1) {
									this.signImg = res.tempFilePath;
									this.judgeSignObj.result = true;
								} else {
									this.customerSignImg = res.tempFilePath;
								}
								await setSyncData('signtures', signture);

								this.sign = false;
								this.customerSign = false;
								this.$nextTick(() => {
									this.getLocalPlan();
									uni.hideLoading();
								});

								return;
							}
							if (type == 1) {
								this.signImg = await this.uploadFile(res.tempFilePath);
							} else {
								this.customerSignImg = await this.uploadFile(res.tempFilePath);
							}

							uni.hideLoading();
							if (type == 1) {
								// debugger
								this.signaturePlan();
							} else {
								this.customSignaturePlan();
							}
						});
					}
				},
			});
		},
		// 签字提交
		signaturePlan() {
			signaturePlan({
				planId: this.planId,
				userId: this.userinfo.user_id,
				signImg: this.signImg,
				signType: 1,
			}).then(async (res) => {
				this.sign = false;
				this.getPlanDetail();
				this.signatureList();
			});
		},
		// 客户签字提交
		customSignaturePlan() {
			console.log('客户签字');
			customSign({
				planId: this.planId,
				signImg: this.customerSignImg,
				signType: 2,
			})
				.then((res) => {
					this.customerSign = false;
					this.signatureList();
					this.getPlanDetail();
				})
				.catch((err) => {
					this.customerSign = false;
					this.getPlanDetail();
					this.signatureList();
				});
		},
		// 获取签字列表
		signatureList() {
			return new Promise((resolve) => {
				signatureList({
					planId: this.planId,
				}).then((res) => {
					try {
						this.setSignRecords(res.data);
					} catch (e) {
						console.log(e);
					}

					resolve();
				});
			});
		},
		uploadFile(url) {
			return new Promise((resove) => {
				this.http
					.upload(url)
					.then((res) => {
						resove(res.data.link || '');
					})
					.catch((err) => {
						resove('');
					});
			});
		},
		async initData() {
			let loacls = await this.getLocals();
			if (!loacls || loacls.length == 0) { 
				uni.hideLoading();
				uni.showModal({
					title: '提示',
					content: '此模板暂无数据，请重新选择',
					success() {
						uni.navigateBack({});
					},
					showCancel: false,
				});
				return;
			}
			await this.getWorkOredrDetail();
			// this.$nextTick(() => {
			// 	this.setSignStyle();
			// });
		},

		// 筛选模板
		async chooseTemplate(item) {
			this.templateId = item.id;
			for (let i = 0; i < this.loacls.length; i++) {
				this.loacls[i].finished = 0;
			}
			uni.showLoading({
				title:'加载中',
			});
			// this.templateTypeVOS = [];
			setTimeout(() => {
				this.filterDatas();
				// uni.pageScrollTo({
				// 	scrollTop: Math.max(this.stickyTop - this.mheight - 50, 0)
				// });
				uni.hideLoading();
				// setTimeout(() => {
				// 	// this.setSignStyle();
				// }, 1000);
			}, 0);
		},

		// 选择部件
		async changeTab(idx, first = true) {
			if (this.editIdx != -1) {
				uni.showToast({
					title: '您还有信息未保存，请保存',
					icon: 'none',
					mask: true,
				});
				return;
			}

			this.tabIdx = first ? idx : this.tabIdx;
			this.filterDatas();
			if (first) { // 非第一次onshow 保留滚动条重置
				uni.pageScrollTo({
					scrollTop: Math.max(this.stickyTop - this.mheight - 50, 0),
				});
				// setTimeout(() => {
				// 	this.setSignStyle();
				// }, 1000);
			}

			return;
		},
		// 选择部件或模板筛选数据
		filterDatas() {
			let local = this.loacls[this.tabIdx] || {}; 
			let filterdata = this.orgTemplate.filter((item) => {
				return (item.tltIds).indexOf(local.tltId || '') != -1 && item.templateId.indexOf(this.templateId || '') != -1;
			});
			let templateTypeVOSMap = {};
			for (let i = 0; i < filterdata.length; i++) {
				let keyword = (filterdata[i].tltIds);
				if (templateTypeVOSMap[keyword]) {
					templateTypeVOSMap[keyword].push(filterdata[i]);
				} else {
					templateTypeVOSMap[keyword] = [filterdata[i]];
				}
			}
			let templateTypeVOS = [];
			for (const key in templateTypeVOSMap) {
				templateTypeVOS.push({
					tltId: key,
					tltName: templateTypeVOSMap[key][0].tltNames,
					workItemCount: templateTypeVOSMap[key].length,
					planTemplateContentVOS: templateTypeVOSMap[key]
				});
			}
			if (filterdata.length) {
				console.log('	this.templateTypeVOS = templateTypeVOS;',templateTypeVOS);
				// if (this.templateTypeVOS.length == 0) {
				// 	this.templateTypeVOS = templateTypeVOS;
				// }
				this.templateTypeVOS = templateTypeVOS;
				// this.templateList = [{ templateName: '全部', templateId: '0', templateTypeVOS }];
			} else {
				this.templateTypeVOS = [];
			}
		},

		// 校验所有工作项
		getAllWorkItems() {
			const showTips = (str = '') => {
				uni.hideLoading();

				uni.showToast({
					title: str || '请完成必填记录的工作项',
					icon: 'none',
					mask: true,
				});
			};

			// 对操作记录 选项分组
			const groupByOptions = (arr) => {
				let map = {};
				for (let i = 0; i < arr.length; i++) {
					for (let j = 0; j < arr[i].recordVOList.length; j++) {
						let idx = arr[i].recordVOList[j].recordDataValue.index;
						if (idx || idx === 0) {
							if (map[idx]) {
								map[idx].push(arr[i].recordVOList[j]);
							} else {
								map[idx] = [arr[i].recordVOList[j]];
							}
						}
					}
				}
				return map;
			};
			return new Promise((resolve, reject) => {
				getAllWorkItems({
					planId: this.planId,
				}).then((res) => {
					let result = true;
					try {
						let list = res.data;
						for (let i = 0; i < list.length; i++) {
							let item = list[i].recordData;
							// console.log(111, item.name, item);

							if (item.type == 1 && item.must) {
								if (!item.userData) {
									// 如果没有选中 查询一下默认选中
									for (let j = 0; j < item.options.length; j++) {
										if (item.options[j].default) {
											item.userData = item.options[j];
											item.userChoose = j;
											break;
										}
									}
									if (!item.userData) {
										result = false;
										showTips();
										reject(item);
										return;
									}
								}

								if (
									(item.userData.files.need && item.userData.files.must) ||
									(item.userData.records.need && item.userData.records.must) ||
									(item.userData.remarks.need && item.userData.remarks.must)
								) {
									if (
										!list[i].userRecordVOS ||
										list[i].userRecordVOS.length == 0
									) {
										result = false;
										console.log('未完成', list[i]);
										showTips('项目' + list[i].name + '需添加一条记录');
										reject(item);
										return;
									}
								}
								if (item.userData.comparison) {
									// 保养前
									if (
										(item.userData.filesBefore.need && item.userData.filesBefore.must) ||
										(item.userData.recordsBefore.need && item.userData.recordsBefore.must) ||
										(item.userData.remarksBefore.need && item.userData.remarksBefore.must)
									) {
										if (
											!list[i].userRecordVOS ||
											list[i].userRecordVOS.length == 0
										) {
											result = false;
											console.log('未完成', list[i]);
											showTips('项目' + list[i].name + '需添加一条保养前记录');
											reject(item);
											return;
										}
										let before = false;
										for (let n = 0; n < list[i].userRecordVOS.length; n++) {
											for (let f = 0; f < list[i].userRecordVOS[n].recordVOList.length; f++) {
												if (list[i].userRecordVOS[n].recordVOList[f].status == 2) {
													before = true;
													break;
												}
											}
											if (before) {
												break;
											}
										}
										if (before == false) {
											result = false;
											console.log('未完成', item.userData, list[i]);
											showTips('项目' + list[i].name + '需添加一条保养前记录');
											reject(item);
											return;
										}
									}

									// 保养后
									if (
										(item.userData.filesAfter.need && item.userData.filesAfter.must) ||
										(item.userData.recordsAfter.need && item.userData.recordsAfter.must) ||
										(item.userData.remarksAfter.need && item.userData.remarksAfter.must)
									) {
										if (
											!list[i].userRecordVOS ||
											list[i].userRecordVOS.length == 0
										) {
											result = false;
											console.log('未完成', list[i]);
											showTips('项目' + list[i].name + '需添加一条保养后记录');
											reject(item);
											return;
										}
										let after = false;
										for (let n = 0; n < list[i].userRecordVOS.length; n++) {
											for (let f = 0; f < list[i].userRecordVOS[n].recordVOList.length; f++) {
												if (list[i].userRecordVOS[n].recordVOList[f].status == 3) {
													after = true;
													break;
												}
											}
											if (after) {
												break;
											}
										}
										if (after == false) {
											result = false;
											console.log('未完成', list[i]);
											showTips('项目' + list[i].name + '需添加一条保养后记录');
											reject(item);
											return;
										}
									}
								}
							} else if (item.type == 2) {// 填空题
								let optMap = groupByOptions(list[i].userRecordVOS || []);// 题型分组
								if (item.min > 0) {
									let num = 0;
									for (let j = 0; j < item.options.length; j++) {
										if (item.options[j].val || item.options[j].val === 0) {
											num++;
										}
									}
									for (let j = 0; j < item.options.length; j++) {
										if (item.options[j].val || item.options[j].val === 0) {
											if (item.options[j].result) {
												let val = Number(item.options[j].val);
												let min = Number(item.options[j].min);
												let max = Number(item.options[j].max);
												let type = (val >= min && val <= max) ? 'in' : 'out';
												let json = item.options[j][type + 'Ranges'];
												if (!json.comparison) {
													if (
														(json.files.need && json.files.must) ||
														(json.records.need && json.records.must) ||
														(json.remarks.need && json.remarks.must)
													) {
														let isFinish = optMap[j] && optMap[j].length ? true : false;

														if (!isFinish) {
															console.log('未完成', list[i], optMap, 1);
															showTips(
																'填空' + item.options[j].name + '需添加一条记录'
															);
															result = false;
															reject(item);
															return;
														}
													}
												}

												if (json.comparison && ((json.filesBefore.need && json.filesBefore.must) || (json.recordsBefore.need && json.recordsBefore.must) || (json.remarksBefore.need && json.remarksBefore.must))
												) {
													let isFinish = false;
													for (let n = 0; n < optMap[j].length; n++) {
														if (optMap[j][n].status == 2) {
															isFinish = true;
															break;
														}
													}

													if (!isFinish) {
														console.log('未完成', list[i], optMap, 2, json, j, type, item.options[j]);
														showTips(
															'填空' + item.options[j].name + '需添加一条保养前记录'
														);
														result = false;
														reject(item);
														return;
													}
												}

												if (json.comparison && ((json.filesAfter.need && json.filesAfter.must) || (json.recordsAfter.need && json.recordsAfter.must) || (json.remarksAfter.need && json.remarksAfter.must))
												) {
													let isFinish = false;
													for (let n = 0; n < optMap[j].length; n++) {
														if (optMap[j][n].status == 3) {
															isFinish = true;
															break;
														}
													}
													if (!isFinish) {
														console.log('未完成', list[i], optMap, 3, json);
														showTips(
															'填空' + item.options[j].name + '需添加一条保养后记录'
														);
														result = false;
														reject(item);
														return;
													}
												}
											}
										}
									}
									if (num < item.min) {
										console.log('未完成', list[i]);
										showTips('项目' + list[i].name + '至少填' + item.min + '项');
										result = false;
										reject(item);
										return;
									}
								}
							} else if (item.type == 3 || item.type == 4) {
								if (item.min > 0 && (!item.val || item.val.length < item.min)) {
									console.log('未完成', list[i]);
									showTips(
										'项目' +
										list[i].name +
										'至少上传' +
										item.min +
										(item.type == 3 ? '张' : '个')
									);
									result = false;
									reject(item);
									return;
								}

								if (
									(item.options.files.need && item.options.files.must) ||
									(item.options.records.need && item.options.records.must) ||
									(item.options.remarks.need && item.options.remarks.must)
								) {
									if (
										!list[i].userRecordVOS ||
										list[i].userRecordVOS.length == 0
									) {
										console.log('未完成', list[i]);
										showTips('项目' + list[i].name + '需添加一条记录');
										result = false;
										reject(item);
										return;
									}
								}

								if (item.options.comparison && ((item.options.filesBefore.need && item.options.filesBefore.must) || (item.options.recordsBefore.need && item.options.recordsBefore.must) || (item.options.remarksBefore.need && item.options.remarksBefore.must))
								) {
									if (
										!list[i].userRecordVOS ||
										list[i].userRecordVOS.length == 0
									) {
										console.log('未完成', list[i]);
										showTips('项目' + list[i].name + '需添加一条保养前记录');
										result = false;
										reject(item);
										return;
									} else {
										let finish = false;
										for (let n = 0; n < list[i].userRecordVOS.length; n++) {
											for (let f = 0; f < list[i].userRecordVOS[n].recordVOList.length; f++) {
												if (list[i].userRecordVOS[n].recordVOList[f].status == 2) {
													finish = true;
													break;
												}
											}

											if (finish) {
												break;
											}
										}
										if (!finish) {
											console.log('未完成', list[i]);
											showTips('项目' + list[i].name + '需添加一条保养前记录');
											result = false;
											reject(item);
											return;
										}
									}
								}

								if (item.options.comparison && ((item.options.filesAfter.need && item.options.filesAfter.must) || (item.options.recordsAfter.need && item.options.recordsAfter.must) || (item.options.remarksAfter.need && item.options.remarksAfter.must))
								) {
									if (
										!list[i].userRecordVOS ||
										list[i].userRecordVOS.length == 0
									) {
										console.log('未完成', list[i]);
										showTips('项目' + list[i].name + '需添加一条保养后记录');
										result = false;
										reject(item);
										return;
									} else {
										let finish = false;
										for (let n = 0; n < list[i].userRecordVOS.length; n++) {
											for (let f = 0; f < list[i].userRecordVOS[n].recordVOList.length; f++) {
												if (list[i].userRecordVOS[n].recordVOList[f].status == 3) {
													finish = true;
													break;
												}
											}
											if (finish) {
												break;
											}
										}
										if (!finish) {
											console.log('未完成', list[i]);
											showTips('项目' + list[i].name + '需添加一条保养后记录');
											result = false;
											reject(item);
											return;
										}
									}
								}
							}
						}
					} catch (error) {
						console.log('error', error);
						result = false;
						resolve(false);
					}

					resolve(result);
				});
			});
		},
		// 检查该工作项是否完成
		setFinishStatus(formData) {
			let finish = true;

			const type = formData.recordData.type;
			const item = formData.recordData;
			if (type == 1) {
				if (!item.userData || item.userChoose === undefined) {
					finish = false;
				} else {
					if (!item.userData.comparison) {
						// 普通记录
						if (
							(item.userData.files.need && item.userData.files.must) ||
							(item.userData.records.need && item.userData.records.must) ||
							(item.userData.remarks.need && item.userData.remarks.must)
						) {
							if (
								!formData.userRecordVOS ||
								formData.userRecordVOS.length == 0
							) {
								finish = false;
							} else {

							}
						}
					} else {
						// 保养前后记录

						// 保养前
						if (
							(item.userData.filesBefore.need && item.userData.filesBefore.must) ||
							(item.userData.recordsBefore.need && item.userData.recordsBefore.must) ||
							(item.userData.remarksBefore.need && item.userData.remarksBefore.must)
						) {
							if (
								!formData.userRecordVOS ||
								formData.userRecordVOS.length == 0
							) {
								finish = false;
							}
							let before = false;
							for (let n = 0; n < formData.userRecordVOS.length; n++) {
								for (let f = 0; f < formData.userRecordVOS[n].recordVOList.length; f++) {
									if (formData.userRecordVOS[n].recordVOList[f].status == 2) {
										before = true;
										break;
									}
								}
								if (before) {
									break;
								}
							}
							if (before == false) {
								finish = false;
							}
						}

						// 保养后
						if (
							(item.userData.filesAfter.need && item.userData.filesAfter.must) ||
							(item.userData.recordsAfter.need && item.userData.recordsAfter.must) ||
							(item.userData.remarksAfter.need && item.userData.remarksAfter.must)
						) {
							if (
								!formData.userRecordVOS ||
								formData.userRecordVOS.length == 0
							) {
								finish = false;
							}
							let after = false;
							for (let n = 0; n < formData.userRecordVOS.length; n++) {
								for (let f = 0; f < formData.userRecordVOS[n].recordVOList.length; f++) {
									if (formData.userRecordVOS[n].recordVOList[f].status == 3) {
										after = true;
										break;
									}
								}
								if (after) {
									break;
								}
							}
							if (after == false) {
								finish = false;
							}
						}
					}
				}
			} else if (item.type == 2) {
				if (item.min > 0) {
					let num = 0;
					for (let j = 0; j < item.options.length; j++) {
						if (item.options[j].val || item.options[j].val === 0 || item.options[j].val === '0') {
							num++;
						}
					}
					for (let j = 0; j < item.options.length; j++) {
						let users = formData['userRecordVOS' + j] || {};
						if (item.options[j].val || item.options[j].val === 0 || item.options[j].val === '0') {
							if (item.options[j].result) {
								let optionsItem = item.options[j];
								let type = (optionsItem.val !== '' && optionsItem.inRangeSet && optionsItem.val >= Number(optionsItem.min) && optionsItem.val <= Number(optionsItem.max)) ? 'in' : 'out';
								let json = item.options[j][type + 'Ranges'];

								if (!json.comparison) {
									// 普通记录校验

									if (item.options[j][type] && (
										(json.files.need && json.files.must) ||
										(json.records.need && json.records.must) ||
										(json.remarks.need && json.remarks.must))
									) {
										let isFinish = false;
										for (let key in users) {
											// 查询是否有当前用户并且符合类型的记录
											if (users[key].list[0].recordDataValue.type == type) {
												isFinish = true;
												break;
											}
										}
										console.log('isFinish', isFinish, users, item.options[j]);
										if (!isFinish) {
											finish = false;
											break;
										}
									}
								} else {
									// 保养前后记录校验 
									if ((json.filesBefore.need && json.filesBefore.must) || (json.recordsBefore.need && json.recordsBefore.must) || (json.remarksBefore.need && json.remarksBefore.must)
									) {
										let isFinish = false;
										for (let key in users) {
											// 查询是否有当前用户并且符合类型的记录
											for (let n = 0; n < users[key].list.length; n++) {
												if (users[key].list[n].status == 2) {
													isFinish = true;
													break;
												}
											}
										}

										if (!isFinish) {
											finish = false;
											break;
										}
									}

									if ((json.filesAfter.need && json.filesAfter.must) || (json.recordsAfter.need && json.recordsAfter.must) || (json.remarksAfter.need && json.remarksAfter.must)
									) {
										let isFinish = false;
										for (let key in users) {
											// 查询是否有当前用户并且符合类型的记录
											for (let n = 0; n < users[key].list.length; n++) {
												if (users[key].list[n].status == 3) {
													isFinish = true;
													break;
												}
											}
										}

										if (!isFinish) {
											finish = false;
											break;
										}
									}
								}
							}
						}
					}
					if (num < item.min) {
						console.log('完成的选项不足', item);
						finish = false;
					}
				}
			} else if (item.type == 3 || item.type == 4) {
				if (item.min > 0 && (!item.val || item.val.length < item.min)) {
					finish = false;
				} else {
					if (!item.options.comparison) {
						// 普通记录 
						if (
							(item.options.files.need && item.options.files.must) ||
							(item.options.records.need && item.options.records.must) ||
							(item.options.remarks.need && item.options.remarks.must)
						) {
							if (
								!formData.userRecordVOS ||
								formData.userRecordVOS.length == 0
							) {
								finish = false;
							}
						}
					} else {
						// 保养前后记录验证
						if ((item.options.filesBefore.need && item.options.filesBefore.must) || (item.options.recordsBefore.need && item.options.recordsBefore.must) || (item.options.remarksBefore.need && item.options.remarksBefore.must)) {
							if (
								!formData.userRecordVOS ||
								formData.userRecordVOS.length == 0
							) {
								finish = false;
							} else {
								let fin = false;
								for (let n = 0; n < formData.userRecordVOS.length; n++) {
									for (let f = 0; f < formData.userRecordVOS[n].recordVOList.length; f++) {
										if (formData.userRecordVOS[n].recordVOList[f].status == 2) {
											fin = true;
											break;
										}
									}

									if (fin) {
										break;
									}
								}
								if (!fin) {
									finish = false;
								}
							}
						}

						if ((item.options.filesAfter.need && item.options.filesAfter.must) || (item.options.recordsAfter.need && item.options.recordsAfter.must) || (item.options.remarksAfter.need && item.options.remarksAfter.must)) {
							if (
								!formData.userRecordVOS ||
								formData.userRecordVOS.length == 0
							) {
								finish = false;
							} else {
								let fin = false;
								for (let n = 0; n < formData.userRecordVOS.length; n++) {
									for (let f = 0; f < formData.userRecordVOS[n].recordVOList.length; f++) {
										if (formData.userRecordVOS[n].recordVOList[f].status == 3) {// 保养后
											fin = true;
											break;
										}
									}

									if (fin) {
										break;
									}
								}
								if (!fin) {
									finish = false;
								}
							}
						}
					}
				}
			}
			// console.log('校验是否已完成', formData, formData.name, finish,this.$root); 
			return finish;
		},

		// 等待校验回调
		awaitTimeOut(t) {
			return new Promise((resove) => {
				setTimeout(() => {
					resove();
				}, t || 2000);
			});
		},

		// 点击提交完成
		async finish() {
			if (this.getPlanRole() == false) {
				return;
			}
			if (!this.onlineStatus) {
				// 离线暂时不开放
				this.offLineTips();
				return;
				this.errorView = null;
				if (this.templateTabs.length > 1) {
					this.templateId = '';
				}

				await this.changeTab(0); // 同步数据
				uni.showLoading({
					title: '请稍后',
					mask: true,
				});
				await this.awaitTimeOut(1500);
				this.callWorkerItemNodes();

				await this.awaitTimeOut(2000);
				if (this.errorView) {// 有未完成工作项
					uni.hideLoading();
					uni.showModal({
						title: '提示',
						content: '您还有必填的工作项未完成，请完成后再提交',
						showCancel: false
					});
					return;
				}
				// 离线
				if (this.isPlanStatus) {
					uni.hideLoading();
					// 未签退
					uni.showModal({
						title: '提示',
						content: '您还没有签退，是否前往签退后再提交？',
						success: (res) => {
							if (res.confirm) {
								// 点击确定
								this.showStatusChangeBeforeLeave(false);
							}
						},
					});
					return;
				}
			}

			uni.showLoading({
				title: '同步中',
				mask: true,
			});
			this.errorView = null;
			if (this.templateTabs.length > 1) {
				this.templateId = '';
			}

			await this.changeTab(0); // 同步数据
			// uni.showLoading({
			// 	title: '请稍后',
			// 	mask: true,
			// });
			await this.awaitTimeOut(1500);

			if (this.onlineStatus) {
				this.finishFuc();
			} else {
				// await setSyncData('changeStatus', { planId: this.planId, elevatorId: this.elevatorId, status: 3 });// 提交离线工单修改状态为已提交
				uni.hideLoading();
				// this.refreshData();
			}

			// this.isOutInState = true;
			// this.visibleShowTwo = true;
		},
		// 验证与提交
		async finishFuc() {
			uni.showLoading({
				title: '校验中',
				mask: true
			});

			this.callWorkerItemNodes();
			let result = await this.getAllWorkItems();
			if (!result) {
				console.log('还有未完成');
				uni.hideLoading();
				// 	uni.showModal({
				// 		title:'提示',
				// 		content:'您还有必填的工作项未完成，请完成后再提交',
				// 		showCancel:false
				// 	})
				return;
			}

			await this.getPlanDetail();

			let cantUsers = [];
			for (let i = 0; i < this.planDetail.users.length; i++) {
				if (this.planDetail.users[i].userId == this.userinfo.user_id) {
					if (
						this.planDetail.users[i].signUser &&
						this.planDetail.users[i].signUser.isPlanStatus
					) {
						uni.hideLoading();
						this.handFinish = true;
						this.showStatusChangeBeforeLeave(true, 1);
						// this.finishOut(1);
						return;
					}
				} else {
					if (
						this.planDetail.users[i].signUser &&
						this.planDetail.users[i].signUser.isPlanStatus
					) {
						cantUsers.push(this.planDetail.users[i].userName);
					}
				}
			}
			if (cantUsers.length > 0) {
				console.log(3);
				uni.hideLoading();
				uni.showModal({
					title: `同伴${cantUsers.join('、')}尚未签退`,
					content: '点击 "取消"，可等待同伴签退后再次提交；点击 "继续"，将强制提交任务。同伴将被系统签退且此次工时不作统计。',
					cancelText: '继续',
					confirmText: '取消',
					confirmColor: '#000000',
					cancelColor: '#576B95',
					success: (res) => {
						console.log(res, 4);
						if (!res.confirm) {
							this.getAiAppeals();
						}
					},
					fail: (err) => {
						console.log(err, 4);
					},
				});
				return;
			} else {
				this.getAiAppeals();
			}
		},
		aiModelClick(res) {
			this.aiResultModel = false;
			this.postPlan(res);
		},
		// 获取是否有为申诉的ai图片
		getAiAppeals(tips = true) {
			return new Promise((resolve) => {
				getAIImages({
					planId: this.planId,
					resultStr: 2
				}).then(res => {
					let waitList = [];
					let list = res.data || [];
					for (let i = 0; i < list.length; i++) {
						if (!list[i].desc) {
							waitList.push(list[i]);
						}
					} 
					this.appealNum = list.length;

					if (waitList.length && tips) {
						this.aiResultModel = true;
						uni.hideLoading();
						resolve(true);
						// uni.showModal({
						// 	title: 'AI检测提示',
						// 	content: '已检测当前工单，当前存在不合规风险图片。若对检测结果有异议，可在工单提交任务后，进行申诉。',
						// 	cancelText: '跳过',
						// 	cancelColor: '#999999',
						// 	confirmText: '前往申诉',
						// 	confirmColor: '#0091FF',
						// 	success: (res) => {
						// 		if (res.confirm) {
						// 			// 前往申诉
						// 			resolve(true);
						// 		} else {
						// 			// 跳过
						// 			resolve(false);
						// 		}
						// 	}
						// });
					} else {
						if (tips) {
							this.postPlan(false);
						}
						resolve(false);
					}
				});
			});
		},
		// 提交任务函数
		async postPlan(toAppeal = false) {
			// 提交之前验证是否有AI不合规图片 toAppeal true前往申诉 false 跳过
			// const toAppeal = await this.getAiAppeals();

			if (toAppeal) {
				this.toAppeal(1);
				return;
			}

			uni.showLoading();
			let localInfo = await this.getLocalInfo();
			uni.hideLoading();

			if (!localInfo.latitude) {
				uni.showModal({
					title: '提示',
					content: '请打开定位，再提交',
					showCancel: false,
				});
				return;
			}
			// 双人操作校验 过滤签到过人员
			if (this.config.cheMultiUser == 1 && this.config.cheMultiWork.indexOf(this.maintainPlanContentExt.auditType) != -1 && this.planDetail.users.filter(item => item.userSignCount > 0).length < 2 && this.planDetail.users.length != 1) {
				this.$refs.multiUserPopup.open();
				return;
			}
			// 工单id白名单 跳过工单作业时长校验
			let whiteIdList = ['1874375258374086657', '1874375259531714561', '1874375261360431106', '1874375260450267138',
				'1874375263176564738', '1874375262258012161', '1874378694222094337', '1874378690522718210', '1874378695119675393',
				'1874378691449659393', '1874378693328707586', '1874378692410155010', '1874379074502860802', '1874379071109668866',
				'1874379067552899073', '1874379072833527810', '1874379066701455362', '1874379069222232065', '1874379071994667010',
				'1874379070136590338', '1874379073668194306', '1874379068387565569'
			];
			// 工单作业时长
			if (!whiteIdList.includes(this.planId) && this.config.cheWorkTimeType == 1 && this.config.cheMultiWorkTime.indexOf(this.maintainPlanContentExt.auditType) != -1 && this.planDetail.workDuration < this.config.cheWorkTime) {
				this.$refs.workTimePopup.open();
				return;
			}
			uni.showModal({
				title: '提示',
				content: '提交任务后将不可修改，是否提交?',
				success: async (res) => {
					if (res.confirm) {
						uni.showLoading({
							title: '提交中',
							mask: true,
						});

						let commitAddress = '';

						// #ifdef MP-WEIXIN   
						let address = await getlocalinfo(
							localInfo.latitude,
							localInfo.longitude
						);
						commitAddress = address.result.address;
						// #endif

						// #ifndef MP-WEIXIN   
						commitAddress = localInfo.address;
						// #endif

						// 计算是否范围内打卡

						/* 定位上报埋点*/
						this.reportAddress({
							longitude: localInfo.longitude,
							latitude: localInfo.latitude,
							userId: this.userinfo.user_id,
							operation: 5,
							planId: this.planId,
							recordType: 1, // 提交
						});
						/* 定位上报埋点 end*/

						finishPlan({
							id: this.planId,
							commitAddress,
							commitLongitude: localInfo.longitude,
							commitLatitude: localInfo.latitude,
						})
							.then((res) => {
								uni.hideLoading();
								uni.showToast({
									title: '提交成功',
								});
								this.removeImgLocalInfo();
								setTimeout(() => {
									this.refreshData();
								}, 500);
							})
							.catch((res) => {
								uni.hideLoading();
								uni.showToast({
									title: res.msg,
									icon: 'none',
								});
								setTimeout(() => {
									this.refreshData();
								}, 1000);
							});
					}
				},
			});
		},

		// 删除图片缓存防止爆内存
		removeImgLocalInfo() {
			try {
				uni.getStorageInfo({
					success(res) {
						const isPureNumber = (str) => /^\d+$/.test(str);
						let keys = res.keys || [];
						for (let i = 0; i < keys.length; i++) {
							if (keys[i].length > 10 && isPureNumber(keys[i])) {
								uni.removeStorage({
									key: keys[i]
								});
							}
						}
						uni.setStorage({
							key: 'imgPaths',
							data: {}
						});
					}
				});
			} catch (error) {
				console.log(error);
			}
		},

		// 写入工作项map 方便取 减少递归次数
		setWorkItemMap(list = [], loaclIds = [], loaclNames = []) {
			for (let i = 0; i < list.length; i++) {
				if (!list[i].userRecordVOS) {
					list[i].userRecordVOS = [];
				}
				let item = {
					...list[i],
					elevatorId: this.elevatorId,
					planId: this.planId
				};
				// keyVal 唯一标识 摸板id+工作项id（防多模板出现相同工作项
				const keyVal = list[i].templateId + '_' + list[i].templateContentId;
				this.workItemMap[keyVal] = JSON.parse(JSON.stringify(item));
			}
		},
		// 初始化部件分类下的工作项id列表
		initLocalIds() {
			let indexs = {};
			for (let i = 0; i < this.loacls.length; i++) {
				this.loacls[i].checkHistorys = {};
				this.loacls[i].finished = 0;
				indexs[this.loacls[i].tltId || 0] = i;
			}
			for (const key in this.workItemMap) {
				let idx = indexs[this.workItemMap[key].tltIds];
				if (idx > 0 || idx === 0) {
					this.loacls[idx].checkHistorys[this.workItemMap[key].templateId + '_' + this.workItemMap[key].templateContentId] = {
						id: this.workItemMap[key].templateContentId,
						templateId: this.workItemMap[key].templateId,
						checkHistoryId: this.workItemMap[key].checkHistoryId,
						finished: false
					};
				}
			}
		},

		// 获取详情列表 first 初次加载
		getWorkOredrDetail(first = true) {
			return new Promise((resolve) => {
				// ,tltId:'1000000000000000100'
				getAllWorkItems({
					planId: this.planId
				})
					.then((res) => {
						this.orgTemplate = res.data || [];
						this.setWorkItemMap(this.orgTemplate);// 遍历初始化每个工作项

						this.initLocalIds();

						this.changeTab(0, first);

						this.$nextTick(() => {
							uni.hideLoading();
						});
						resolve(res.data);
					})
					.catch((err) => {
						uni.hideLoading();
					});
			});
		},

		// 获取位置列表
		getLocals() {
			return new Promise((resolve) => {
				getLoaclTypes({ planId: this.planId }).then((res) => {
					let arr = res.data.location || [];
					let num = 0;
					for (let i = 0; i < arr.length; i++) {
						num = num + arr[i].workItemCount;
						arr[i].finished = 0;
					}
					arr.unshift({ tltName: '全部', workItemCount: num, finished: 0 });
					this.loacls = arr; 

					let templateTabs = res.data.template || [];
					if (templateTabs.length > 0 && this.templateTabs.length == 0) {
						this.templateId = res.data.template[0].id;
					}
					if (templateTabs.length > 1) {
						templateTabs.unshift({ name: '全部', id: '' });
					}

					this.templateTabs = templateTabs;
					resolve(res.data);
				});
			});
		},
		handleBack() {
			uni.navigateBack({});
		},

		// 验证是否有权限

		getPlanRole() { 
			let next = false;
			for (let i = 0; i < this.planDetail.users.length; i++) {
				if (this.planDetail.users[i].userId == this.userinfo.user_id) {
					next = true;
					break;
				}
			}
			if (this.offlineDetail.userIds) {
				// 离线数据
				if (this.offlineDetail.userIds.indexOf(this.userinfo.user_id) != -1) {
					next = true;
				}
			}
			if (!next) {
				uni.showModal({
					title: '提示',
					content: '你没有权限操作该任务',
					showCancel: false,
				});
			}
			return next;
		},

		offLineTips() {
			uni.showModal({
				content: '当前离线模式无法进行此操作,请检查网络恢复在线模式再试试',
				title: '提示',
				showCancel: false,
			});
		},
		// 开始签字
		toSign() {
			if (!this.onlineStatus) {
				this.offLineTips();
				return;
			}
			if (this.getPlanRole() == false) {
				return;
			}
			uni.pageScrollTo({
				scrollTop: 100,
			});
			this.sign = true;
		},
		// 客户签字按钮
		async customerHandleSign() {
			console.log('客户签字');
			if (this.judgeSignObj.result) {
				if (this.status == 4) {
					uni.showToast({
						icon: 'none',
						title: '已完成签字',
					});
					return;
				}
				if (!this.onlineStatus) {
					this.customerSign = true;
					return;
				}
				await this.getPlanDetail();
				if (this.status == 5) {
					this.customerSign = true;
				}
				if (this.status == 4) {
					uni.showToast({
						icon: 'none',
						title: '已完成签字',
					});
				}
			} else {
				// 如果不能签字提示
				let nameList = this.judgeSignObj.userList.map((item) => {
					return `【${item.name}】`;
				});
				let str = nameList.join(',');
				console.log(str, 'str的值');
				uni.showModal({
					title: '提示',
					content: str + '还未完成任务签字提交，无法进行客户签字',
				});
			}
		},

		// 刷新与同步
		postOffRecord() {
			uni.showLoading({
				title: '刷新中',
				mask: true
			});
			this.refreshData();
		},
		// 底部开始签到
		async nextStepFuc() {
			if (this.getPlanRole() == false) {
				return;
			}

			if (!this.onlineStatus) {
				let waitPlan = uni.getStorageSync('workingPlans');
				let plans = waitPlan ? waitPlan.split(',') : [];
				for (let i = 0; i < plans.length; i++) {
					const syncData = await getSyncData(plans[i]);
					if (syncData && syncData.signList && syncData.signList.length) {
						if (plans[i] != this.planId && !syncData.signList[syncData.signList.length - 1].signOutTime) {
							// 还有别的没签退的离线数据
							uni.showModal({
								title: '提示',
								content: '您还有其他离线工单没签退，请签退后再签到',
								showCancel: false
							});
							return;
						}
					}
				}
				// if (waitPlan && waitPlan != this.planId) {
				//   uni.showModal({
				//     title: '提示',
				//     content: '您还有其他未同步的离线工单，请保持网络畅通同步之后再签到',
				//     showCancel: false
				//   })
				//   return
				// }

				this.handFinish = false;
				this.signFuc();

				return; // 签到无网 离线
			}

			uni.showLoading({
				title: '加载中',
				mask: true,
			});
			let date = new Date(
				(this.planDetail.planDate || this.offlineDetail.planDate).replace(
					/-/g,
					'/'
				)
			);
			let now = new Date();
			now.setHours(0, 0, 0);
			console.log(now.getTime() + 1000 * 60 * 60 * 24 + 2000, date.getTime());
			if (date.getTime() > now.getTime() + 1000 * 60 * 60 * 24 - 2000) {
				uni.hideLoading();
				uni.showModal({
					title: '提示',
					content: '任务未到可执行时间',
					showCancel: false,
				});
				return true;
			}

			// 判断是否还有未签退的工单
			let isAllow = await this.checkAllowSignFun();
			console.log(isAllow, 'isAllow');
			if (!isAllow) {
				if (this.offLineSignRecord.planId) {
					uni.showToast({
						title: '您还有离线签到未同步，无法签到其他工单',
						icon: 'none',
					});
					uni.hideLoading();
					return;
				}

				this.handFinish = false;
				this.signFuc();

				return; // 签到无网 离线
			}
			if (isAllow.isExist) {
				console.log('isAllow',isAllow);
				uni.hideLoading();
				// uni.showToast({
				//   title: isAllow.msg,
				//   icon: "none",
				//   mask: true,
				// });
				this.checkCanSignOutMsg = isAllow;
				this.signOutModelVisible = true;
				return;
			}
			// let localInfo = await this.getLocalInfo();
			// if (!localInfo.latitude) {
			//   uni.hideLoading();
			//   uni.showModal({
			//     title: "提示",
			//     content: "请打开定位，再签到",
			//     showCancel: false,
			//   });
			//   return;
			// }
			// //计算是否范围内打卡
			// let distance = getDistance(
			//   localInfo.latitude,
			//   localInfo.longitude,
			//   this.eleInfo.latitude,
			//   this.eleInfo.longitude
			// );
			// if (distance > this.$config.maxDistance) {
			//   uni.hideLoading();
			//   uni.showToast({
			//     icon: "none",
			//     title: "偏离项目定位签到",
			//     mask: true,
			//   });
			// }
			uni.hideLoading();
			setTimeout(() => {
				this.handFinish = false;
				this.signFuc();
			}, 300);
		},

		changeImg(res) {
			this.imgaddress = res[0];
		},
		// 签到确定
		async finishSign(e) {
			if (e != 1) {
				uni.hideLoading();
				this.$refs.popup.close('center');
				return;
			}
			let that = this;

			if (this.imgaddress) {
				await this.getPlanDetail();
				if (this.signType == 'in') {
					if (this.status >= 3 || this.isPlanStatus) {
						uni.hideLoading();
						uni.showModal({
							title: '提示',
							content: '签到失败，工单状态已改变',
							showCancel: false,
						});
						return;
					}
				} else {
				}

				let localInfo = await this.getLocalInfo();
				let address = await getlocalinfo(
					localInfo.latitude,
					localInfo.longitude
				);
				let signStatus = 1;
				// 计算是否范围内打卡
				let distance = getDistance(
					localInfo.latitude,
					localInfo.longitude,
					this.eleInfo.latitude,
					this.eleInfo.longitude
				);
				if (distance > this.$config.maxDistance) {
					signStatus = 2;
				}
				// uni.hideLoading()
				// return

				(this.signType == 'in' ? signIn : signOut)(
					this.signType == 'in'
						? {
							userId: that.userinfo.user_id,
							planId: that.planId,
							signImage: that.imgaddress,
							signStatus: signStatus,
							signLongitude: localInfo.longitude,
							signLatitude: localInfo.latitude,
							signAddress: address.result.address,
						}
						: {
							userId: that.userinfo.user_id,
							planId: that.planId,
							signOutImage: that.imgaddress,
							signOutStatus: signStatus,
							signOutLongitude: localInfo.longitude,
							signOutLatitude: localInfo.latitude,
							signOutAddress: address.result.address,
						}
				).then((res) => {
					uni.hideLoading();
					uni.showToast({
						title: '提交成功',
						icon: 'none',
						mask: true,
					});
					setTimeout(() => {
						if (this.signinData.post) {
							// 立即执行提交
							that.imgaddress = '';
							that.$refs.popup.close();
							this.finish();
						} else {
							that.imgaddress = '';
							that.$refs.popup.close();
							that.refreshData();
						}
						if (this.signType == 'in') {
							this.visibleShowTwo = true;
						}
					}, 700);
				});
			} else {
				uni.hideLoading();
				uni.showToast({
					title: '请拍照',
					icon: 'none',
				});
			}
		},

		// 拨打电话
		handleCall() {
			this.$nextTick(() => {
				this.$refs.property.$refs.propertyPhone.open();
			});
		},
		closePhone() {
			this.$nextTick(() => {
				this.$refs.property.$refs.propertyPhone.close();
			});
		},
		// 签到
		async signFuc(obj = {}) {
			let _this = this;

			this.signType = 'in';
			this.signinData = obj;
			// this.$refs.popup.open('center');
			let data = {
				signType: this.signType == 'in' ? 1 : 2,
				useLastImg: this.useLastImg,
				orderType: 1,
			};
			uni.setStorage({
				key: 'signObj',
				data,
			});
			console.log(this.config.malSignIn, this.lastSignImg, '上次图片');
			// return
			if (this.config.cheSignIn == 1) {
				if (this.lastSignImg && this.lastSignImg.signImage && this.onlineStatus) {
					this.visibleShowLastImg = true;
				} else {
					uni.navigateTo({
						url: `/pages/sign/index?planId=${this.planId}&elevatorId=${this.elevatorId}`,
					});
				}
			} else {
				uni.navigateTo({
					url: `/pages/sign/index?planId=${this.planId}&elevatorId=${this.elevatorId}`,
				});
			}
		},
		getConfig() {
			return new Promise((resolve) => {
				getConfig().then((res) => {
					if (res) {
						this.config = res.data.config;
					}
				});
				resolve();
			});
		},
		movableChange(e) {
			// console.log('movableChange', e)
			let x = e.touches[0].pageX - 56 / 2;
			let y = e.touches[0].clientY - 56 / 2;
			if (x < 8) {
				x = 8;
			}
			if (x > 330) {
				x = 330;
			}
			if (y < 70) {
				y = 70;
			}
			if (y > this.movable.height + 5) {
				y = this.movable.height + 5;
			}
			this.movable.x = x;
			this.movable.y = y;
		},
		touchend(res) {
			if (this.movable.x < 156) {
				this.movable.x = 8;
			} else {
				this.movable.x = this.movable.width - 55;
			}
		},
		// 是否使用上次签到签退照片
		comfireUseLastImg(res) {
			this.useLastImg = res;
			let data = {
				signType: this.signType == 'in' ? 1 : 2,
				useLastImg: this.useLastImg,
				orderType: 1,
			};
			if (this.buttonType === 1) {
				data.buttonType = 1;
			}
			uni.setStorage({
				key: 'signObj',
				data,
			});
			this.visibleShowLastImg = false;
			uni.navigateTo({
				url: `/pages/sign/index?planId=${this.planId}&elevatorId=${this.elevatorId}&isFinsh=${this.handFinish}`,
			});
		},
		// 预计完成时间弹框
		showChooseDate() {
			if (this.offline) {
				// this.offLineTips()
				this.showState = true;
				this.$refs.weekYear.$refs.chooseDate.open();
				return;
			}
			if (this.userSignCount == 0) {
				uni.showToast({
					title: '请先签到,再进行操作',
					icon: 'none',
					mask: true,
				});
				return;
			}

			this.$nextTick(() => {
				this.showState = true;
				this.$refs.weekYear.$refs.chooseDate.open();
			});
		},
		bindClose() {
			this.$nextTick(() => {
				this.showState = false;
				this.$refs.weekYear.$refs.chooseDate.close();
			});
		},
		selectChange(res) { 
			if (this.offline) {
				// 离线模式保存到缓存
				this.offLineSignRecord.finishDate = res.date;
				uni.setStorage({
					key: 'offline_sign_record',
					data: this.offLineSignRecord,
				});
				return;
			}
			this.finishDate = res.date;
			let timeArr = res.date.replace(' ', ':').replace(/\:/g, '-').split('-');
			this.dateArr = timeArr;
			// 这里需要请求数据
			this.handleTimeUpdate();
		},
		// 修改预计时间请求数据
		handleTimeUpdate() {
			uni.showLoading({
				title: '请求中',
				icon: 'none',
			});
			timeUpdate({
				id: this.planId,
				finishDate: `${this.finishDate}${this.finishDate && this.finishDate.length < 18 ? ':00' : ''}`,
			}).then((res) => {
				if (res) {
					uni.hideLoading();
					// this.getDetail();
					this.getPlanDetail();
				}
			});
		},
		// 距离是否正常
		isDistanceNomal() {
			return new Promise(async (reslove) => {
				let localInfo = await this.getLocalInfo();
				let isNormal = true;
				if (!localInfo.latitude) {
					isNormal = false;
					uni.showToast({
						icon: 'none',
						title: '无定位',
						mask: true,
					});
				}
				// 计算是否范围内打卡
				let distance = getDistance(
					localInfo.latitude,
					localInfo.longitude,
					this.eleInfo.latitude,
					this.eleInfo.longitude
				);
				if (distance > this.$config.maxDistance) {
					isNormal = false;
					uni.showToast({
						icon: 'none',
						title: `偏离项目定位${this.signType == 'in' ? '签到' : '签退'}`,
						mask: true,
					});
				} else {
					isNormal = true;
				}
				reslove(isNormal);
			});
		},
		checkAllowSignFun() {
			return new Promise((resolve) => {
				checkCanSignOut({ planId: this.planId })
					.then((res) => {
						if (res) {
							resolve(res.data);
						}
					})
					.catch((err) => {
						resolve(false);
					});
			});
		},
		backToList() {
			uni.navigateBack({});
		},
		// 项目别名弹窗
		petName(obj) {
			this.popupShow = true;
			this.overflowShow = true;
			this.aliasArr = (obj.relationAlias || []).map((item) => item.alias);
		},
		closedMask(e) {
			this.overflowShow = false;
			this.popupShow = false;
		},
		closeTooltip() {
			this.$refs.tooltip.close();
		},
		getPlanLogs() {
			getPlanLogs({
				planId: this.planId
			}).then(res => {
				this.remarkLength = res.data.length;
			});
		}
	},
};
</script>
<style>
page {
	background: #f3f6f8;
	width: 750rpx;
	padding: 0;
	margin: 0;
	background-color: #f3f6f8;
	overflow-x: hidden;
	overflow-y: scroll;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: none;
	/* 全页面禁用 */
}
</style>

<style lang="scss" scoped>
.work-detail {
	width: 100%;
}

.main {
	background-color: #f3f6f8;
}

.nabvar {
	position: fixed;
	top: 0;
	z-index: 100;
}

.signCircle {
	height: 80rpx;
	width: 80rpx;
	display: flex;
	justify-content: center;
	align-items: center;
	background: #0091ff;
	color: #fff;
	position: fixed;
	z-index: 112;
	border-radius: 50%;
}

.add {
	background: #0091ff;
	color: #fff;
	font-size: 26rpx;
}

.finishDateContent {
	display: flex;
	justify-content: space-between;
	padding-bottom: 24rpx;
	color: #666;
	border-bottom: 2rpx solid #e9e9e9;
	margin-bottom: 22rpx;

	.label {
		font-size: 26rpx;
	}

	.timeArea {
		display: flex;
		align-items: center;
		font-size: 24rpx;

		image {
			width: 32rpx;
			height: 32rpx;
		}
	}
}

.aa {
	position: fixed;
	z-index: 102;
	width: 100%;
	overflow: auto;
	background-color: #fff;
	box-shadow: 0rpx 4rpx 12rpx 0rpx rgba(0, 0, 0, 0.12);
}

.header {
	background: #f3f6f8;
	// height: 266rpx;

	.bg {
		width: 376rpx;
		height: 366rpx;
		position: absolute;
		top: 0;
		right: 0;
	}

	.header_item {
		padding: 28rpx 20rpx;
		padding-left: 38rpx;
	}

	.header_top {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 4rpx;
		position: relative;
		z-index: 300;

		.header_top_left {
			font-size: 42rpx;
			color: #333;
			font-weight: bold;
			width: 540rpx;
		}
	}

	.header_bottom {
		font-size: 24rpx;
		color: #666;
		position: relative;
		z-index: 100;
		margin-top: 10rpx;
	}

	.header_bottomTops {
		text:nth-child(1) {
			padding-right: 10rpx;
			border-right: 1rpx solid #ccc;
		}

		text:nth-child(2) {
			padding-left: 10rpx;
		}
	}
}

.statusArea {
	padding: 10rpx 20rpx;
	background: #ffffff;
	border-radius: 8rpx;
	display: flex;
	font-size: 26rpx;
	position: absolute;
	font-weight: 500;
	right: 0rpx;
	top: 10rpx;
	z-index: 120;

	image {
		width: 32rpx;
		height: 32rpx;
	}
}

.addressBox {
	width: calc(100% - 22rpx - 16rpx);
	margin: 0 auto;
	background: #fff;
	border-radius: 8rpx;
	font-size: 24rpx;
	padding: 20rpx 22rpx 16rpx 16rpx;
	font-size: 24rpx;
	color: #999;
	box-sizing: border-box;
	margin-bottom: 20rpx;
	position: relative;
	z-index: 9;
	display: flex;

	.top {
		display: flex;

		.name {
			display: flex;
			// padding-left: 14rpx;
			font-weight: 600;
			color: #333;
			align-items: center;
		}

		image {
			width: 32rpx;
			height: 32rpx;
		}
	}

	.buildAddressBox {
		display: flex;
	}

	.buildAddress {
		padding: 6rpx 20rpx 0 32rpx;
		margin-left: 10rpx;
		width: 388rpx;
		margin-right: 30rpx;

		.buildings {
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
			max-width: 388rpx;
			font-size: 20rpx;
			color: #666;
		}
	}

	.addressBox_right {
		display: flex;
		flex: 1;
		justify-content: flex-end;

		align-items: center;
	}

	.gpsAndCall {
		position: relative;
		display: flex;
		align-items: center;
		width: 190rpx;

		.gpsAndCall_item {
			display: flex;
			flex: 1;
			color: #666;
		}

		.guide {
			justify-content: flex-end;
		}

		image {
			width: 32rpx;
			height: 32rpx;
		}

		.line {
			width: 2rpx;
			height: 24rpx;
			background: #e9e9e9;
			position: absolute;
			left: 50%;
			top: 6rpx;
		}
	}
}

.headers {
	width: 100%;
	overflow: hidden;
	position: relative;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;

	&-bg {
		width: 750rpx;
		height: 354rpx;
		padding-top: 40rpx;
		// background: linear-gradient(0deg, #deedf8, #deedf8);
		border-bottom-left-radius: 50%;
		border-bottom-right-radius: 50%;
		// box-shadow: 5px 10px 15px #e3eff8;
		position: absolute;
		top: 0;
	}

	.stepContent {
		margin: 0 20rpx;

		.stepItme {
			background-color: #fff;
			border-radius: 8rpx;
			padding-top: 32rpx;

			&-title {
				height: 88rpx;
				font-size: 32rpx;
				font-weight: bold;
				text-align: left;
				color: #333333;
				line-height: 88rpx;
				padding: 0 20rpx;
				border-bottom: 2rpx solid #e9e9e9;
			}
		}

		.steps {
			padding: 0 20rpx;
			z-index: 9;
			// margin: 30rpx 0;
			margin-bottom: 0;
			background: #fff;
			border-radius: 8rpx;
			// width: 710rpx;
			box-sizing: border-box;
		}

		.userListBox {
			padding: 0 20rpx;
			padding-bottom: 20rpx;
		}
	}

	.progressBar_elevator {
		width: 710rpx;
		margin: 0 auto;
		background: #fff;
		border-radius: 8rpx;
		margin-bottom: 20rpx;
		margin-top: 15rpx;
		display: flex;
		height: 84rpx;
		line-height: 84rpx;
		z-index: 300;

		view:nth-of-type(1) {
			flex: 1;
			font-size: 32rpx;
			font-weight: 700;
			color: #333333;
			margin-left: 20rpx;
		}

		view:nth-of-type(2) {
			flex: 0 0 200rpx;
			text-align: right;
			font-size: 26rpx;
			color: #0091ff;
			border-radius: 8rpx;
			padding: 0rpx 30rpx;
			vertical-align: middle;

			text {
				margin-right: 8rpx;
			}

			image {
				width: 32rpx;
				height: 32rpx;
				vertical-align: middle;
			}
		}
	}

	.remark-btn {
		width: 710rpx;
		margin: 0 auto;
		background: #fff;
		border-radius: 8rpx;
		margin-bottom: 16rpx;
		display: flex;
		height: 84rpx;
		align-items: center;
		justify-content: space-between;
		padding: 0 20rpx;
		box-sizing: border-box;
		font-size: 26rpx;
	}

	.progressBar_planTime {
		width: calc(100% - 40rpx);
		margin: 0 auto;
		background: #fff;
		border-radius: 8rpx;
		margin-bottom: 16rpx;
		display: flex;
		height: 84rpx;
		align-items: center;
		justify-content: space-between;
		padding: 0 20rpx;
		box-sizing: border-box;

		.planTime_tit {
			display: flex;
			align-items: center;

			view:nth-of-type(1) {
				flex: 1;
				font-size: 26rpx;
				font-weight: 400;
				color: #666;

				.planBar {
					font-size: 24rpx;
					font-weight: 400;
					color: #e02020;
					background: #ffe3e3;
					padding: 0 10rpx;
					margin-left: 5rpx;
					border-radius: 4rpx;
				}
			}

			view:nth-of-type(2) {
				flex: 1;
				font-size: 26rpx;
				font-weight: 400;
				color: #999;
				text-align: right;
				margin-right: 20rpx;

				text:nth-of-type(2) {
					display: inline-block;
					width: 12rpx;
					height: 12rpx;
					border-right: 2rpx #999 solid;
					border-top: 2rpx #999 solid;
					transform: rotate(45deg);
					margin-bottom: 3rpx;
				}
			}
		}

		.planTime_date {
			display: flex;

			view:nth-of-type(1) {
				flex: 1;
				font-size: 32rpx;
				font-weight: 700;
				color: #333333;
				margin-left: 20rpx;

				text {
					font-size: 24rpx;
					font-weight: 400;
					color: #0091ff;
					vertical-align: middle;
				}

				image {
					width: 32rpx;
					height: 32rpx;
					vertical-align: middle;
					margin-left: 8rpx;
				}
			}

			view:nth-of-type(2) {
				flex: 1;
				font-size: 26rpx;
				font-weight: 400;
				color: #999;
				text-align: right;
				margin-right: 20rpx;

				text {}

				image {
					width: 28rpx;
					height: 28rpx;
					vertical-align: middle;
					margin-bottom: 7rpx;
				}
			}
		}
	}

	.mark {
		z-index: 9;
		background: linear-gradient(0deg,
				rgba(243, 246, 248, 1),
				rgba(243, 246, 248, 0));
	}

	&-info {
		.header_item {
			display: flex;
			justify-content: space-between;
		}

		.toInfo {
			position: relative;
			z-index: 100;
		}

		margin: 0rpx 40rpx;
		z-index: 9;
		position: relative;
		padding: 20rpx 0;
		padding-top: 40rpx;

		// background-color: linear-gradient(0deg,rgba(226, 239, 248, 0.931), rgba(226, 239, 248, 0.931));
		&-name {
			font-size: 42rpx;
			color: #333;
			font-weight: bold;
			width: 560rpx;
			display: flex;
			flex-wrap: wrap;
		}

		&-tag {
			font-size: 24rpx;
			color: #999;
			padding-top: 7rpx;
		}

		.next-btn {

			// position: absolute;
			// bottom: 30rpx;
			// right: 0;
			// z-index: 99;
			image {
				width: 32rpx;
				height: 32rpx;
			}
		}

		.top_R {
			position: absolute;
			top: 50rpx;
			right: 0;
			z-index: 99;
			display: flex;
			align-items: center;

			image {
				width: 32rpx;
				height: 32rpx;
			}
		}
	}
}

.allcheck {
	width: 154rpx;
	height: 48rpx;
	padding-right: 8rpx;
	font-size: 24rpx;
	border: 2rpx solid #e9e9e9;
	color: #333;
	transition: 0.3s all;
	border-radius: 8rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	vertical-align: middle;
	font-weight: normal;

	image {
		width: 32rpx;
		height: 32rpx;
		padding-right: 3rpx;
	}
}

.allcheckAct {
	border: 2rpx solid #6bc013;
	color: #6bc013;
}

.card {
	width: calc(100% - 40rpx);
	background-color: #fff;
	// min-height: 1100rpx;
	border-radius: 8rpx;
	margin: 20rpx auto;
	position: relative;
	-webkit-overflow-scrolling: touch;

	.title {
		font-size: 32rpx;
		font-weight: bold;
		text-align: left;
		color: #333333;
		padding: 28rpx 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.score_content {
		display: flex;
		align-items: top;
		font-size: 28rpx;
		color: #333;
		padding: 10rpx 0;

		>.label {
			color: #999999;
			width: 160rpx;
		}

		.msg {
			width: calc(100% - 160rpx);

			.tags {
				border: 2rpx solid #0091ff;
				border-radius: 8rpx;
				color: #0091ff;
				padding: 6rpx 10rpx;
				margin-right: 10rpx;
				line-height: 30rpx;
				display: inline-block;
				margin-bottom: 6rpx;
			}
		}
	}

	.sticky {
		// position: sticky !important;

		// width: 750rpx !important;
		background-color: #fff;
		z-index: 100;
		left: 0rpx;
		width: 100%;
	}

	.temp-list {
		width: 100%;
		margin-top: 20rpx;
		padding-bottom: 240rpx;

		&-name {
			border-left: 5rpx solid #0091ff;
			padding-left: 16rpx;
			font-size: 32rpx;
			font-weight: bold;
			color: #333;
		}
	}

	.sign-item {
		width: calc(100% - 40rpx);
		padding: 20rpx;

		&-name {
			font-size: 28rpx;
			color: #333;
			font-weight: 600;
			padding-bottom: 20rpx;
			position: relative;
		}

		&-line {
			width: 4rpx;
			height: 28rpx;
			background: #0091ff;
			top: 4rpx;
			left: -20rpx;
			position: absolute;
		}
	}
}

.signCard {
	background-color: #f3f6f8;

	.card_item {
		background-color: #fff;
		border-radius: 8rpx;
		margin-bottom: 16rpx;
	}
}

.footer-block {
	width: 100%;
	height: 200rpx;
}

.canvas {
	margin: 20rpx auto;
	border-radius: 4rpx;
	overflow: hidden;
}

.signimg {
	display: block;
	border: 1rpx dashed #ccc;
	margin: 0 auto
}

.sign-btns {
	display: flex;
	justify-content: flex-end;
	padding: 30rpx 20rpx;

	&-item {
		padding: 0 20rpx;
		height: 60rpx;
		background: #0091ff;
		border-radius: 4rpx;
		text-align: center;
		line-height: 60rpx;
		font-size: 26rpx;
		color: #666666;
		border: 2rpx solid #cccccc;
		background-color: #fff;
		margin-left: 30rpx;
	}

	&-item:last-child {
		color: #ffffff;
		margin-left: 20rpx;
		border: 2rpx solid #0091ff;
		background-color: #0091ff;
	}
}

.footer {
	width: 94%;
	height: 98rpx;
	padding: 5rpx 3%;
	background: #ffffff;
	position: fixed;
	z-index: 99;
	bottom: 0;
	display: flex;
	justify-content: center;
	align-items: center;
	border-top: 2rpx solid #eee;

	&-item {
		width: 100rpx;
		text-align: center;
		line-height: 25rpx;
		color: #666;
		font-size: 26rpx !important;

		image {
			width: 48rpx;
			height: 48rpx;
		}
	}

	.btn {
		flex: 1;
		height: 70rpx;
		background: #0091ff;
		border-radius: 8rpx;
		text-align: center;
		font-size: 28rpx !important;
		line-height: 70rpx;
		color: #fff;
		// margin-left: 20rpx;
	}

	.repair {
		background: #f5fbff;
		border-radius: 8rpx 0rpx 0rpx 8rpx;
		color: #0091ff;
	}

	.disabled {
		background-color: #ccc;
	}
}

.change_elevator {
	display: flex;
	flex-direction: row;
	justify-content: center;

	.actElevator {
		// background-color: #0091ff;
		font-size: 24rpx !important;
		color: #0091ff !important;
		border: 2rpx #0091ff solid !important;
	}

	view:nth-of-type(1) {
		// background-color: #0091ff;
		color: #666;
		height: 72rpx;
		width: 176rpx;
		line-height: 72rpx;
		text-align: center;
		border-radius: 8rpx;
		border: 2rpx #ccc solid;
		font-size: 28rpx;
		margin-right: 32rpx;
	}

	view:nth-of-type(2) {
		color: #666;
		height: 72rpx;
		width: 176rpx;
		line-height: 72rpx;
		text-align: center;
		border-radius: 8rpx;
		border: 2rpx #ccc solid;
		font-size: 28rpx;
	}
}

.special_tit {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;

	.tit_up {
		font-size: 28rpx;
		font-weight: 500;
		color: #000000;
		margin-bottom: 20rpx;
		width: 360rpx;
		text-indent: -40rpx;
		margin-left: 40rpx;
	}

	.tit_dwn {
		font-size: 24rpx;
		text-align: center;
		color: #666666;
	}
}

.template-tabs {
	width: 100%;
	overflow-x: scroll;
	border-left: 4rpx solid #0091ff;
	margin-top: 20rpx;
	white-space: nowrap;

	.template-item {
		display: inline-block;
		color: #666666;
		padding: 8rpx 30rpx;
		border-radius: 2rem;
		background-color: #f3f6f8;
		margin-right: 16rpx;
		transition: .2s all;

	}

	.act {
		background-color: #dcf0ff;
		color: #0091ff;
	}

	.template-item:first-child {
		margin-left: 16rpx;
	}
}

.template-tabs::-webkit-scrollbar {
	width: 0;
	height: 0;
	color: transparent;
	display: none
}

.sign-dialog {
	width: 100%;
	height: 100vh;
	position: fixed;
	top: 0;
	left: 0;
	z-index: 1001;
	background: #fff
}

.camera-dialog {
	width: 100%;
	height: 100vh;
	position: fixed;
	top: 0;
	left: 0;
	z-index: 1001;
	background: #000
}

.empty {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	width: 100%;
	height: 300rpx;
	padding-bottom: 200rpx;

	.circle {
		width: 64rpx;
		height: 64rpx;
	}

	image {
		width: 64rpx;
		height: 64rpx;
	}

	&-title {
		font-size: 26rpx;
		color: #999;
		font-weight: 400;
		margin-top: 10rpx;
	}
}

.appeal-btn {
	position: fixed;
	bottom: 50vh;
	right: 0rpx;
	display: flex;
	width: 100rpx;
	align-items: center;
	border-bottom-left-radius: 2rem;
	border-top-left-radius: 2rem;
	font-size: 28rpx;
	padding: 10rpx 8rpx 10rpx 20rpx;
	vertical-align: unset;
	font-weight: normal;
	background-color: #fff;
	box-shadow: 0rpx 2rpx 6rpx 0rpx rgba(126, 138, 146, 0.3095);
	color: #0091FF;
	z-index: 99;

	background-color: #fff;

	&-ico {
		width: 28rpx !important;
		height: 28rpx !important;
		margin-right: 4rpx;
	}

}

.bottom {
	font-size: 22rpx;
	font-family: PingFangSC, PingFangSC-Regular;
	font-weight: 400;
	text-align: center;
	color: #fa6400;
	line-height: 32rpx;
	height: 32rpx;
	padding: 0 10rpx;
	background: #fff0e6;
	border-radius: 16rpx;
}

.multiUser {
	background: #FFFFFF;
	border-radius: 4px 4px 0px 0px;
	box-shadow: 0px -2px 6px 0px rgba(0, 0, 0, 0.1181);

	.multiUser_title {
		padding: 20rpx 48rpx;
		padding-bottom: 16rpx;

		.line {
			width: 64rpx;
			height: 10rpx;
			background: #D8D8D8;
			border-radius: 5rpx;
			margin: auto;
		}

		.tips {
			font-size: 32rpx;
			font-weight: 500;
			color: #333333;
		}
	}

	.multiUser_content {
		padding: 20rpx 48rpx;

		.content_tips {
			color: #333333;
			font-size: 32rpx;
			font-weight: 500;
		}

		.content_remarks {
			color: #666666;
			font-size: 24rpx;
			margin: 8rpx 0 24rpx;
		}

		.people_box {
			display: flex;
			align-items: center;
			flex-wrap: wrap;

			.people {
				background: #B9B9B9;
				width: 112rpx;
				height: 112rpx;
				border-radius: 50%;
				color: #fff;
				line-height: 112rpx;
				text-align: center;
				margin-top: 20rpx;
				margin-right: 24rpx;
				position: relative;

				.tags {
					width: 100rpx;
					height: 32rpx;
					box-sizing: border-box;
					background: #FDF1E9;
					padding: 0px 8rpx;
					text-align: center;
					position: absolute;
					bottom: 0;
					left: 6rpx;
					z-index: 1;
					font-size: 24rpx;
					line-height: 32rpx;
					color: #FA6400;
					border-radius: 4rpx;
				}

				.signOn {
					background: #DCF0FF;
					color: #0091FF;
				}
			}

			.signOnPeople {
				background: #0091FF;
			}
		}
	}

	.multiUser_bottom {
		padding: 16rpx 40rpx 24rpx 40rpx;

		.btn {
			height: 68rpx;
			background: #0091FF;
			border-radius: 8rpx;
			color: #FFFFFF;
			font-weight: 500;
			line-height: 68rpx;
			font-size: 28rpx;
			text-align: center;
		}
	}
}
</style>
